You're viewing help content for version:
- 6.5
- 6.4
- 6.3
- Older Versions
Hide conditions can be used to determine if a component resource is rendered or not. An example of this would be when an template author configures the Core Component list component in the template editor and decides to disable the options to build the list based on child pages. Disabling this option in the design dialog sets a property so that when the list component is rendered, the hide condition is evaluated and the option to show child pages is not displayed.
Dialogs can become very complex with numerous options for the user, who may only use a fraction of the options that are at his/her disposal. This can lead to overwhelming user interface experiences for users.
By using hide conditions, admins, developers, and super users have a way to hide resources based on a set of rules. This feature allows them to decide what resources should be displayed when an author edits content.
Note:
Hiding a resource based on an expression does not replace ACL permissions. Content remains editable but is simply not displayed.
com.adobe.granite.ui.components.FilteringResourceWrapper is responsible filtering the resources based on the existence and value of the granite:hide property, located on the field to be filtered. The implementation of /libs/cq/gui/components/authoring/dialog/dialog.jsp includes an instance of FilteringResourceWrapper.
The implementation makes use of the Granite ELResolver API and adds a cqDesign custom variable via the ExpressionCustomizer.
Here are a few examples of hide conditions on a design node located either under etc/design or as a Content Policy.
${cqDesign.myProperty} ${!cqDesign.myProperty} ${cqDesign.myProperty == 'someText'} ${cqDesign.myProperty != 'someText'} ${cqDesign.myProperty == true} ${cqDesign.myProperty == true} ${cqDesign.property1 == 'someText' && cqDesign.property2 || cqDesign.property3 != 1 || header.myHeader}
When defining your hide expression keep in mind:
- To be valid, the scope in which property is found should be expressed (e.g. cqDesign.myProperty).
- Values are read only.
- Functions (if required) should be limited to a given set provided by the service.
Examples of hide conditions can be found throughout AEM and the core components in particular. For example, consider the list core component.
Using the template editor, the template author can define in the design dialog which options of the list component that are available to the page author. Such options as whether to allow the list to be a static list, a list of child pages, a list of tagged pages, etc. can be enabled or disabled.
If a template author chooses to disable the child pages option, a design property is set and a hide condition is evaluated against it, which causes the option to not render for the page author.
-
The value of disableChildren is pulled from the design configuration and the expression ${cdDesign.disableChildren} evaluates to false, meaning the option will not be rendered as part of the component.
You can view the hide expression as the value of the granite:hide property in GitHub here.