Skip to content

Instantly share code, notes, and snippets.

@kevinweber
Last active February 21, 2023 14:44
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kevinweber/5812f6b670d8ae8d3bfc7bd1ad204b7c to your computer and use it in GitHub Desktop.
Save kevinweber/5812f6b670d8ae8d3bfc7bd1ad204b7c to your computer and use it in GitHub Desktop.
AEM: Sling Resource Merging & Includes (dialog, inheriting properties)
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured">
<content jcr:primaryType="nt:unstructured">
<items jcr:primaryType="nt:unstructured">
<basic jcr:primaryType="nt:unstructured">
<items jcr:primaryType="nt:unstructured">
<column jcr:primaryType="nt:unstructured">
<items jcr:primaryType="nt:unstructured">
<toggable
jcr:primaryType="nt:unstructured"
sling:hideResource="true"/>
</items>
</column>
</items>
</basic>
</items>
</content>
</jcr:root>

Official documentation: https://docs.adobe.com/docs/en/aem/6-1/develop/platform/sling-resource-merger.html#Properties

Sling Resource Merging with AEM docs can be found here. Specifically look through the docs for the resource merger properties and how you can manipulate different properties.

The resource merger provides the following properties:

sling:hideProperties (String or String[]) Specifies the property, or list of properties, to hide. The wildcard * hides all.

sling:hideResource (Boolean) Indicates whether the resources should be completely hidden, including its children.

sling:hideChildren (String or String[]) Contains the child node, or list of child nodes, to hide. The properties of the node will be maintained. The wildcard * hides all.

sling:orderBefore (String) Contains the name of the sibling node that the current node should be positioned in front of.

These properties affect how the corresponding/original resources/properties (from /libs) are used by the overlay/override (often in /apps).

How to reuse existing dialog elements in other dialogs?

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

The xtype "cqinclude" can be used to include nodes from a different dialog or JSON file: https://docs.adobe.com/docs/en/aem/6-2/develop/components/xtypes.html

How to get the JSON representation of an element?

Everything in AEM can be accessed in JSON format. For example: /apps/core-project/components/content/bl16-quote/_cq_dialog.json

If you want to access/include something more specific: /apps/core-project/components/content/bl16-quote/_cq_dialog/content/items.json

If you add .infinity, you get the selected node plus all children: /apps/core-project/components/content/bl16-quote/_cq_dialog.infinity.json

A number gives you a certain depth of children: /apps/core-project/components/content/bl16-quote/_cq_dialog.2.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment