Component included by using data-sly-resource in a page template not generating the included component in the content/page folder

manasip 04-06-2018

Page Rendering Script: homepage.html

<!--/* Banner */-->

<div data-sly-resource="${'banner' @resourceType='/apps/web/platform/components/content/banner'}"></div>

On the page  http://localhost:4502/editor.html/content/home.html  I can see banner component. But when I go to /content/home/jcr:content there is no banner component found.

Once banner component is authored we can see the component on /content/home0/jcr:content

Is this the expected behavior?AEM - Questions​@

Accepted Solutions (1)

Accepted Solutions (1)

Arun_Patidar
MVP
04-06-2018

1. you need to create a node e.g. banner under template jcr:content node i.e. /apps/web/platform/templates/page-content/jcr:content e.g.

/apps/web/platform/templates/page-content/jcr:content/banner

2. add sling:resourceType property to banner node i.e.  sling:resourceType = /apps/web/platform/components/content/banner

3. call banner component in page like

<!--/* Banner */-->

<div data-sly-resource="banner"></div>

Thanks

Arun

Answers (3)

Answers (3)

manasip 04-06-2018

Thanks Arun for Reply. you got my requirement exactly.

Can you please ellaborate more? I tried below statement instead of above statement.

<div data-sly-resource="${'banner' @resourceType='/apps/web/platform/components/content/banner', decorationTagName='div'}"></div>

but no output using this on homepage.html.

Arun_Patidar
MVP
04-06-2018

Hi,

It seems this is the default behaviour.

If you want to add banner in jcr:content as soon as page created.

You can add banner component in template like title component in screenshot below:

Screen Shot 2018-06-04 at 11.35.02 AM.png

Thanks

Arun