Quantcast
Channel: CQ 5
Viewing all articles
Browse latest Browse all 35

[DIALOG] REUSING TABS OR FIELDS FROM AN EXISTING DIALOG WITH CQINCLUDE

$
0
0

How to reuse existing dialog elements in other dialogs


Given that we have a dialog:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
   jcr:primaryType="cq:Dialog"
   xtype="dialog">
   <items
       jcr:primaryType="cq:Widget"
       xtype="tabpanel">
       <items jcr:primaryType="cq:WidgetCollection">
           <cta
               jcr:primaryType="cq:Panel"
               title="CTA">
               <items jcr:primaryType="cq:WidgetCollection">
               <background
                       jcr:primaryType="cq:Widget"
                       fieldLabel="Background Color"
                       name="./background"
                       fieldDescription="Hex value (#FFFFFF) or ARGB value (argb(255,255,255,0.0))"
                       regex="/(^rgba\\(\\s*(0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*((0.[1-9])|[01])\\s*\\)$)|(^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$)/"
                       xtype="textfield"/>
               </items>
           </cta>
       </items>
   </items>
</jcr:root>


1. Re-use property:

‘background’ property has path: /apps/{yourapp}/components/ctacomp/dialog/items/items/cta/items/background


This path will be pasted into a property on your new dialog with the extension “.infinitiy.json” added to the end.
/apps/{yourapp}/components/ctacomp/dialog/items/items/cta/items/background.infinity.json


Other property can re-use ‘background’ property like:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
   jcr:primaryType="cq:Dialog"
   xtype="dialog">
   <items
       jcr:primaryType="cq:Widget"
       xtype="tabpanel">
       <items jcr:primaryType="cq:WidgetCollection">
           <header
               jcr:primaryType="cq:Panel"
               title="Header">
               <items jcr:primaryType="cq:WidgetCollection">
                   <signin
                       jcr:primaryType="cq:Widget"
                       fieldLabel="Sign-in"
                       name="./signin"
                       xtype="textfield"/>
      <background
                       jcr:primaryType="cq:Widget"
                       path="/apps/{yourapp}/components/ctacomp/dialog/items/items/cta/items/background.infinity.json"
                       xtype="cqinclude"/>
               </items>
           </header>
       </items>
   </items>
</jcr:root>



1. Re-use tab:

Use path = /apps/{yourapp}/components/ctacomp/dialog/items/items/cta.infinity.json to re-use 'cta' tab.

Viewing all articles
Browse latest Browse all 35

Trending Articles