Template Senarios | Community
Skip to main content
Level 3
July 22, 2022
Solved

Template Senarios

  • July 22, 2022
  • 4 replies
  • 1336 views

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? 

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 Sachin_Arora_

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

 

 

4 replies

Mohit_KBansal
Adobe Employee
Adobe Employee
July 22, 2022

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

Sachin_Arora_
Community Advisor
Sachin_Arora_Community AdvisorAccepted solution
Community Advisor
July 22, 2022

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

 

 

HariDoAuthor
Level 3
July 23, 2022

@sachin_arora_ Thank you for the answer it worked 

 

Level 3
July 22, 2022

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

arunpatidar
Community Advisor
Community Advisor
July 22, 2022

Hi,

Please check https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/templates/templates.html?lang=en#template-availability 

 

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
Level 6
January 19, 2024

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)?