Regex for allowedPaths to hide template after some levels level | Community
Skip to main content
Level 2
July 25, 2022
Solved

Regex for allowedPaths to hide template after some levels level

  • July 25, 2022
  • 2 replies
  • 1037 views

Hi Team,I have a template (xyz), I want to hide this template after 4 levels from my project root content (mysite). let's say /content/mysite/dynamicvalue/dynamicvalue/dynamicvalue/dynamicvalue/

 

Please provide me regex for allowedPaths.

 

bit urgent requirement, Thanks in advance 

 

 

 

 

 

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 Tushar_Gupta

Template Availability - 

AEM offers multiple properties to control the templates allowed under Sites. However, combining them can lead to very complex rules that are difficult to track and manage.

Therefore, Adobe recommends that you start simple, by defining:

  • only the cq:allowedTemplates property

  • only on the site root

For an example, see We.Retail: /content/we-retail/jcr:content

The properties allowedPaths, allowedParents, and allowedChildren can also be placed on the templates to define more sophisticated rules. However, when possible, it is much simpler to define further cq:allowedTemplates properties on sub-sections of the site if there is a need to further restrict the allowed templates.

An additional advantage is that the cq:allowedTemplates properties can be updated by an author in the Advanced tab of the Page Properties. The other template properties cannot be updated using the (standard) UI, so would need a developer to maintain the rules and a code deployment for every change.

 

The following properties determine whether a template T is allowed to be used for a new page to be placed as a child of page P. Each of these properties is a multi-value string holding zero or more Regular Expressions that are used for matching with paths:

  • The cq:allowedTemplates property of the jcr:content subnode of P or an ancestor of P.

 

Refer fore more details - https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/templates/templates.html?lang=en 

 

2 replies

SantoshSai
Community Advisor
Community Advisor
July 25, 2022

Hi @gskittu ,

Try this,

/content/mysite/([^/]*)/([^/]*)/([^/]*)/([^/]*)

OR

/content/mysite/(.*)/(.*)/(.*)/(.*) 

Regards,

Santosh 

Santosh Sai
gskittuAuthor
Level 2
July 26, 2022

Hi @santoshsai , Thanks for your reply, Your both regex are enabling template after 4 levels, but in my case I want to enable till 4th level and hide after 4th level

Tushar_GuptaAdobe EmployeeAccepted solution
Adobe Employee
July 26, 2022

Template Availability - 

AEM offers multiple properties to control the templates allowed under Sites. However, combining them can lead to very complex rules that are difficult to track and manage.

Therefore, Adobe recommends that you start simple, by defining:

  • only the cq:allowedTemplates property

  • only on the site root

For an example, see We.Retail: /content/we-retail/jcr:content

The properties allowedPaths, allowedParents, and allowedChildren can also be placed on the templates to define more sophisticated rules. However, when possible, it is much simpler to define further cq:allowedTemplates properties on sub-sections of the site if there is a need to further restrict the allowed templates.

An additional advantage is that the cq:allowedTemplates properties can be updated by an author in the Advanced tab of the Page Properties. The other template properties cannot be updated using the (standard) UI, so would need a developer to maintain the rules and a code deployment for every change.

 

The following properties determine whether a template T is allowed to be used for a new page to be placed as a child of page P. Each of these properties is a multi-value string holding zero or more Regular Expressions that are used for matching with paths:

  • The cq:allowedTemplates property of the jcr:content subnode of P or an ancestor of P.

 

Refer fore more details - https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/templates/templates.html?lang=en