Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Template component can't override page.html

Avatar

Avatar
Validate 25
Level 4
B_Stockwell
Level 4

Likes

16 likes

Total Posts

105 posts

Correct Reply

7 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 5
Boost 3
View profile

Avatar
Validate 25
Level 4
B_Stockwell
Level 4

Likes

16 likes

Total Posts

105 posts

Correct Reply

7 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 5
Boost 3
View profile
B_Stockwell
Level 4

08-06-2017

I have 2 templates:

  1. /apps/uc-base/components/templates/content-page
    1. sling:resourceSuperType: uc-base/components/templates/global
  2. /apps/uc-base/components/templates/global
    1. sling:resourceSuperType: wcm/foundation/components/page

The global template has a file named "page.html" but when the page loads, it still runs the page file  at wcm/foundation/components/page/page.html resulting in some errors (specifically, the page doesn't have "structure support", as it's a static template).

Do I have something in my setup wrong? I'd like to be able to use some pieces of the base page component but it looks like I mihgt just have to copy that whole folder and cut out the pieces I want.

I'm in aem 6.2

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

449 likes

Total Posts

1,024 posts

Correct Reply

116 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

449 likes

Total Posts

1,024 posts

Correct Reply

116 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
Veena_Vikram
MVP

08-06-2017

Hi Stockwell

          I am not sure if I understood your question well. But if you are confused with the sling resolution The Basics  this will be a good read for you.

         Let me try to explain what might have gone wrong in your case

     Let’s say you are creating a page with /apps/uc-base/components/templates/global template, Now the first thing sling will look for is a page named global.html. If it is not present then it will check for the parent (sling:resourceSuperType)

     Here, your parent page, wcm/foundation/components/page, when invoked will look for page.html (assuming you don't have any specific extensions in your URL. Lets keep it simple ) under its folder name and not the child. It will look under child only when the page.html have an include and if that file is present in the child with same name. For eg:- In the below screenshot wcm/foundation/components/page , the page.html
1225688_pastedImage_3.png

     at line 20 has a include to body.html.  Sling will first look for this file under /apps/uc-base/components/templates/global, if it is not present then as per precedence it will look under wcm/foundation/components/page


So, to solve your problem, the pieces you want to use from the base page, should be included as a body.html under your /apps/uc-base/components/templates/global so that your resolution picks up this file while running.

PS:- Its not always mandatory you have to add body.html only, but to make sure the foundation page is included in your structure, make sure your base page starts with body.html and further whatever you want to include just keep adding on that . Sling resolution is a big concept which cannot be explained here with due respect to all its concepts. I am sorry if I confuse you more

     I think once you have a better understanding on Sling resolution this would be a cake walk . Below are some good reads

Apache Sling - URL decomposition

Sling Cheatsheet - docs.adobe.com

  The concepts remain same whether in 5.6 or in 6.3

  Hope this helps and too much of explanation has not confused you

Thanks

Veena


Answers (2)

Answers (2)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

09-06-2017

Also - a good practice is to have:

apps/<you_project>/template

apps/<you_project>/component

Avatar

Avatar
Validate 1
Employee
Knennigtri
Employee

Likes

9 likes

Total Posts

13 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Give Back
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Employee
Knennigtri
Employee

Likes

9 likes

Total Posts

13 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Give Back
Boost 5
Boost 3
Boost 1
View profile
Knennigtri
Employee

08-06-2017

Based on:

  1. /apps/uc-base/components/templates/content-page
    1. sling:resourceSuperType: uc-base/components/templates/global
  2. /apps/uc-base/components/templates/global
    1. sling:resourceSuperType: wcm/foundation/components/page

If you are expecting a script /apps/uc-base/components/templates/global/page.html to override /libs/wcm/foundation/components/page/page.html, this will not work. You need the script to be the default script in your global template component. To do this simply change ~/global/page.html to ~/global/global.html and your script will be run rather than the /libs/foundation/

Good luck!