Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Regex for allowedPaths to hide template after some levels level

Avatar

Level 2

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 

 

 

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 7

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/template... 

 

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @gskittu ,

Try this,

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

OR

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

Regards,

Santosh 

Avatar

Level 2

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

Avatar

Correct answer by
Level 7

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/template...