Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Editable Template for specific pages

Avatar

Level 2

I  hv a requirement using the same editable template I have to create 10 pages out of which 5 pages' header footer complete layout is different from the other 5 pages. How to achieve this with one editable template

Please help me with this urgent requirement.

 

Thank You.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @divanshjohndigital There are multiple ways to achieve the use case mentioned by you based on the business requirement. 

Requirement I : (based on the locale the header/footer has to a different layout)

fetch the url of the current page and get the locale

@ScriptVariable
private Page currentPage;

String pagePath = currentPage.getPath();
final String[] = pagePath.split(SLASH);
final String locale = pagePath.startsWith(PATH_CONTENT) ? String.format("%s%s%s", split[4], HYPHEN, split[5]) : StringUtils.EMPTY;

Now based on the locale you can auotmatically decide which layout needs to be displayed.

 

Requirement II (displayed the layout based on the selection within the footer/header):

Shailesh_Bassi__0-1681148093777.png

Reference you using the initial content is as follows:

https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/templates/page-tem...

Hope this helps!

Thanks

 

View solution in original post

3 Replies

Avatar

Community Advisor

 

  • If you don't want to use experience fragments it's better to separate the template. Create 2 different templates from the base template types.

 

 

 

Avatar

Community Advisor

@divanshjohndigital In case there is a limited number of pages, I suggest you unlock the experience fragment component on an editable template and let the AEM content author select the experience fragment path in every newly created page. Otherwise, create separate editable templates by considering the first template path structure as sling resourceType.

Avatar

Correct answer by
Community Advisor

Hi @divanshjohndigital There are multiple ways to achieve the use case mentioned by you based on the business requirement. 

Requirement I : (based on the locale the header/footer has to a different layout)

fetch the url of the current page and get the locale

@ScriptVariable
private Page currentPage;

String pagePath = currentPage.getPath();
final String[] = pagePath.split(SLASH);
final String locale = pagePath.startsWith(PATH_CONTENT) ? String.format("%s%s%s", split[4], HYPHEN, split[5]) : StringUtils.EMPTY;

Now based on the locale you can auotmatically decide which layout needs to be displayed.

 

Requirement II (displayed the layout based on the selection within the footer/header):

Shailesh_Bassi__0-1681148093777.png

Reference you using the initial content is as follows:

https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/templates/page-tem...

Hope this helps!

Thanks