Expand my Community achievements bar.

Join expert-led, customer-led sessions on Adobe Experience Manager Assets on August 20th at our Skill Exchange.
SOLVED

How to have shared cq_dialog

Avatar

Level 2
Consider I have 2 components (both of them footer section) cq_dialog of footer has 3 fields 1) Title 2) Content 3) Image How do I share the cq_dialog between my 2 components. Is there any other way than direct copy pasting stuff
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @KunalNa1 ,

 

I would suggest to reuse tabs or containers of the dialog and include them via special resource type. See details below.

 

Firstly, you have to extract your reusable configuration to a separate place like: /apps/project/components/authoring/dialog/footer.

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
    jcr:primaryType="nt:unstructured">
    <tab_configuration
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/coral/foundation/container">
        <items jcr:primaryType="nt:unstructured">
            
        </items>
    </tab_configuration>
</jcr:root>

Secondly, you have to include extracted piece of configuration by using sling:resourceType="granite/ui/components/coral/foundation/include".

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
    jcr:primaryType="nt:unstructured"
    jcr:title="Footer"
    sling:resourceType="cq/gui/components/authoring/dialog">
    <content
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/coral/foundation/container">
        <items jcr:primaryType="nt:unstructured">
            <tabs
                jcr:primaryType="nt:unstructured"
                sling:resourceType="granite/ui/components/coral/foundation/tabs"
                maximized="{Boolean}true">
                <items jcr:primaryType="nt:unstructured">
                    <configurationtab
                        jcr:primaryType="nt:unstructured"
                        sling:resourceType="granite/ui/components/coral/foundation/include"
                        path="/mnt/overlay/project/components/authoring/dialog/footer/tab_configuration"/>
                </items>
            </tabs>
        </items>
    </content>
</jcr:root>

 

Kostiantyn Diachenko



Check out AEM VLT Intellij plugin


View solution in original post

3 Replies

Avatar

Community Advisor

Just use sling:resourceSuperType=<component path which has cq:dialog> on other component property.

Avatar

Correct answer by
Community Advisor

Hi @KunalNa1 ,

 

I would suggest to reuse tabs or containers of the dialog and include them via special resource type. See details below.

 

Firstly, you have to extract your reusable configuration to a separate place like: /apps/project/components/authoring/dialog/footer.

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
    jcr:primaryType="nt:unstructured">
    <tab_configuration
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/coral/foundation/container">
        <items jcr:primaryType="nt:unstructured">
            
        </items>
    </tab_configuration>
</jcr:root>

Secondly, you have to include extracted piece of configuration by using sling:resourceType="granite/ui/components/coral/foundation/include".

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
    jcr:primaryType="nt:unstructured"
    jcr:title="Footer"
    sling:resourceType="cq/gui/components/authoring/dialog">
    <content
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/coral/foundation/container">
        <items jcr:primaryType="nt:unstructured">
            <tabs
                jcr:primaryType="nt:unstructured"
                sling:resourceType="granite/ui/components/coral/foundation/tabs"
                maximized="{Boolean}true">
                <items jcr:primaryType="nt:unstructured">
                    <configurationtab
                        jcr:primaryType="nt:unstructured"
                        sling:resourceType="granite/ui/components/coral/foundation/include"
                        path="/mnt/overlay/project/components/authoring/dialog/footer/tab_configuration"/>
                </items>
            </tabs>
        </items>
    </content>
</jcr:root>

 

Kostiantyn Diachenko



Check out AEM VLT Intellij plugin


Avatar

Level 4

Adobe recommends modular development with emphasis on reusability. You can create multiple components by leveraging same cq:dialog using their sling resourceType and resourceSuperType. You can read more about it over here: https://forums.adobe.com/external-link.jspa?url=http%3A%2F%2Fwem.help.adobe.com%2Fenterprise%2Fen_US...

 

These super types are also considered when trying to find a script (especially for handling dialog validations). The advantage of resource super types is that they may form a hierarchy of resources where the default resource type sling/servlet/default (used by the default servlets) is effectively the root.

Also - see the SLing docs. This is a good topic to start with:

https://sling.apache.org/documentation/the-sling-engine/url-to-script-resolution.html