Component included by using data-sly-resource in a page template not generating the included component in the content/page folder | Community
Skip to main content
Level 2
June 4, 2018
Solved

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

  • June 4, 2018
  • 4 replies
  • 11382 views

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​@

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

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

4 replies

arunpatidar
Community Advisor
Community Advisor
June 4, 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:

Thanks

Arun

Arun Patidar
manasipAuthor
Level 2
June 4, 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.

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
June 4, 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

Arun Patidar
smacdonald2008
Level 10
June 4, 2018

If you are using 6.3/6,4 - it's best practice to use editable templates and put the header/banner in the editable template, as discussed here:  Scott's Digital Community: Creating an Adobe Experience Manager 6.4 website using Editable Templates