Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

Template Senarios

Avatar

Level 3

If I have two templates A and B whenever I create a page under template A but it should always use template B how should I achieve that? 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You can use cq:allowedTemplates  property to allow specific templates to be visible under a path. 

You can set this property on /conf/project/settings/wcm/templates/template-a/initial/jcr:content of the Template A. So once the author creates a page using Template A, the page will have Template B as cq:allowedTemplates property and Authors can choose only Template B to create a page under it.

 

Reference  : /content/we-retail/jcr:content

sachinarora_0-1658492306715.png

 

 

View solution in original post

6 Replies

Avatar

Employee Advisor

Its quite a strange use case. Are both templates identical ? 

Avatar

Correct answer by
Community Advisor

You can use cq:allowedTemplates  property to allow specific templates to be visible under a path. 

You can set this property on /conf/project/settings/wcm/templates/template-a/initial/jcr:content of the Template A. So once the author creates a page using Template A, the page will have Template B as cq:allowedTemplates property and Authors can choose only Template B to create a page under it.

 

Reference  : /content/we-retail/jcr:content

sachinarora_0-1658492306715.png

 

 

Avatar

Level 4

You can use cq:allowedTemplates property to define specific templates. Set property in a way that only Template B is available for use.

Avatar

Community Advisor

Hi,

Please check https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/templates/template... 

 

These properties allows you to set some contract of structure of pages in you project. For example: you have 3 templates (and corresponding pages with this templates):

  • template-1: allowedChildren="[template-2]"
  • template-2: allowedChildren="[template-3]"
  • template-3: allowedChildren="[]"

Then in siteadmin, you will be able to create:

  • under page with template "template-1" only pages with template "template-2",
  • under page with template "template-2" only pages with template "template-3",
  • under page with template "template-3" you will not be able to create any page.


Arun Patidar

Avatar

Level 7

Hi @arunpatidar 

Do you set the cq:allowedTemplates, allowedParents and allowedChlidren on the jcr:content node under context.xml in the initial folder (arrow on top) or context.xml on the root folder (arrow at the bottom)?

 

anasustic_0-1705668142498.png