Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

AEM - How to restrict a template from showing in a certain path

Avatar

Level 2

Hi!,

I wonder if someone has achieved what I'll post here. In order to allow a template to be created under a certain path, there is a flag allowedPaths that receives a regex.

So, if I want my template "test" to appear only under /content/www/xx/xx/test-templates and child elements, I can do this:

    

/content/www/.*/.*/test-templates(/.*)?

 

But what if I want to make the opposite? I want the template "test" to appear in every /content/www/xx/xx/ node and beyond, EXCEPT /content/www/xx/xx/test-templates and children?

I have tried several ways but no luck so far. Do you have some hint regarding this?

 

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 2
6 Replies

Avatar

Level 10

See this KB:

https://helpx.adobe.com/experience-manager/kb/LimitChildPages.html

But there does not seem to be a way to restrict only a part of an allowed JCR path. 

Avatar

Level 2

Thank you sir! I took a look at that article and also asked this question http://stackoverflow.com/questions/34905975/aem-how-to-restrict-a-template-from-showing-in-a-certain.... There's a promising comment there, which probably I could use with allowedPaths in order to restrict those paths that does not match the given regex.

I'll post my results here in a few :)

Avatar

Employee Advisor

You can try the following pattern for this use case-

^/content/www/xx/xx/(?!(test-templates)).*$

Avatar

Community Advisor

Hi,

I found the pattern content\/www\/xxx\/xxx\/xxx\/legal\/(?!(test)).*$ this will work for your usecase 

Kunal i think same as ur regex may be i am late :)

 

Thanks

Mani Kumar K

Avatar

Level 2

Thank you! but those xx are intended to be anything (.*) and when you do this the regex changes :-\

Avatar

Correct answer by
Level 2

At the end it seems that http://stackoverflow.com/questions/34905975/aem-how-to-restrict-a-template-from-showing-in-a-certain... response worked as expected.

 

Thank you all!