You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Andreas Schaefer Sr." <sc...@me.com> on 2017/03/21 19:16:04 UTC

Sling Resource Rendering Inheritance

Hi

As a long time CQ / AEM backend developer I ran into some issues
to adjust to Sling.

I have a resource ‘Home Page’ that should render a JCR node as
a HTML page. The Home page component then only adjust
the layout of the Body and Head and the rest should be inherited from
its Resource Super Type “Page’. I tried that but it does not render
without the home.html as well as the footer missing in Home is not
picked up.

This is my configuration:

1. JCR Content Node (/content/sample/home)

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
          jcr:primaryType="nt:unstructured"
          jcr:title="Sample Home"
          jcr:description="Sample Home Page"
          sling:resourceType="sample/home"
          sling:resourceSuperType="sample"
/>

2. Home Page configuration (/apps/sample/home):

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
          jcr:primaryType="sling:Folder"
          jcr:title="Sample Home Page Component"
          jcr:description="Sample Home Page Component woth HTL"
          sling:resourceSuperType="sample/page"
/>

This only contains the head.html and body.html file.

3. Page Configuration (/apps/sample/page):

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
          jcr:primaryType="sling:Folder"
          jcr:title="Sample Page Component"
          jcr:description="Sample Page Component"
/>

This contains the page.html which includes the head, body and footer.html file.

This setup does not work and I could only make it work by providing the /apps/sample/home/home.html.

Any way to make the work like in AEM?

I am pretty sure that I don’t see the forest because of the trees here
but I could not figure out how to do it right even when looking at the
Sling Samples.

Thanks - Andy Schaefer

Re: Sling Resource Rendering Inheritance

Posted by "Andreas Schaefer Sr." <sc...@me.com>.
Sorry, wrong mailing list.

- Andy

> On Mar 21, 2017, at 12:16 PM, Andreas Schaefer Sr. <sc...@me.com> wrote:
> 
> Hi
> 
> As a long time CQ / AEM backend developer I ran into some issues
> to adjust to Sling.
> 
> I have a resource ‘Home Page’ that should render a JCR node as
> a HTML page. The Home page component then only adjust
> the layout of the Body and Head and the rest should be inherited from
> its Resource Super Type “Page’. I tried that but it does not render
> without the home.html as well as the footer missing in Home is not
> picked up.
> 
> This is my configuration:
> 
> 1. JCR Content Node (/content/sample/home)
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
>          jcr:primaryType="nt:unstructured"
>          jcr:title="Sample Home"
>          jcr:description="Sample Home Page"
>          sling:resourceType="sample/home"
>          sling:resourceSuperType="sample"
> />
> 
> 2. Home Page configuration (/apps/sample/home):
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
>          jcr:primaryType="sling:Folder"
>          jcr:title="Sample Home Page Component"
>          jcr:description="Sample Home Page Component woth HTL"
>          sling:resourceSuperType="sample/page"
> />
> 
> This only contains the head.html and body.html file.
> 
> 3. Page Configuration (/apps/sample/page):
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
>          jcr:primaryType="sling:Folder"
>          jcr:title="Sample Page Component"
>          jcr:description="Sample Page Component"
> />
> 
> This contains the page.html which includes the head, body and footer.html file.
> 
> This setup does not work and I could only make it work by providing the /apps/sample/home/home.html.
> 
> Any way to make the work like in AEM?
> 
> I am pretty sure that I don’t see the forest because of the trees here
> but I could not figure out how to do it right even when looking at the
> Sling Samples.
> 
> Thanks - Andy Schaefer