Show/Hide Page Properties/tabs based on Template paths in AEM

Show/Hide Page Properties/tabs based on Template paths in AEM

This blog is an extension to show/hide page properties for multiple templates from my ex-colleague Ahmed Musallam’s post How to show/hide page properties based on a single template path.

In AEM , editable templates usually share the same page component, which means the same page properties dialog.

Below are the steps to show/hide page properties based on the template paths.

  1. Create a servlet

    2.   Now you can add a granite:rendercondition node under any of your properties to show/hide them based on template path. Here is an example:

<granite:rendercondition

                            jcr:primaryType=“nt:unstructured”

                            sling:resourceType=“utils/granite/rendercondition/simple/sites-apps”

                            templatePaths=“[/conf/mysite/settings/wcm/templates/field2-page,/conf/mysite/settings/wcm/templates/template1]”/>

Following render condition shows the whole tab for templates matching /conf/mysite/settings/wcm/templates/field2-page or /conf/mysite/settings/wcm/templates/template1 

Section1 properties (field1, another field) will be shown for template matching /conf/mysite/settings/wcm/templates/template1

Section2 properties (field2 will be shown for template matching /conf/mysite/settings/wcm/templates/template2

granite renderceondition for a section only allows elements to be visible for templates defined in for allowedPaths property. allowedPaths is multifield, any number of templates can be added to this property.

With the custom code and render condition you may be able to define multiple template paths on which you want to show the custom properties.

References:

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/show-hide-page-properties-based-on-template-in-aem-aem-community/m-p/377744

https://aem4beginner.blogspot.com/granite-custom-render-conditions-using

Shaji Ahmed

Experience with creating strategies and design solutions for enterprise content management and e-commerce using AEM Planning and leading projects through enterprise-level CMS conversions. SME in providing architectural solution advice and solutions to problems faced by global AEM community.

No Comments

Sorry, the comment form is closed at this time.