Every page in CQ5 can have an image attached to it in page properties. I need to add my own image property to be used in a component.
I am able to add small things as a check box using this link but when I add a new image tab in the page properties, even the existing image stops working.
Even if I can add another image dialog in the page, I am unable to fetch the new image. This is the new image dialog I've added. (see attachment)
I just want to use the image in the carousel [maybe fetch it using :
Resource r = page.getContentResource("image1");
Can someone please help me on this ? What properties do I at least need to make it work ?
You need to use an xtype of smartimage (or a version of this, e.g. html5smartimage).
Here's some sample code that will add two images in a dialog — imageOne and imageTwo. You need to make sure that the properties of your new image don't conflict with the existing one — namely the fileNameParameter, fileReferenceParameter, name and the name of the child node resType should be unique in the example below.
<items jcr:primaryType="cq:TabPanel">
<items jcr:primaryType="cq:WidgetCollection">
<imageOnePanel
jcr:primaryType="cq:Panel"
title="Image One Panel">
<items jcr:primaryType="cq:WidgetCollection">
<imageOne
jcr:primaryType="cq:Widget"
border="true"
ddGroups="[media]"
fileNameParameter="./imageOne/fileName"
fileReferenceParameter="./imageOneFileReference"
height="300"
hideLabel="true"
name="./imageOne/file"
xtype="html5smartimage">
<items jcr:primaryType="cq:WidgetCollection">
<resType
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./imageOne/sling:resourceType"
value="foundation/components/image"
xtype="hidden"/>
</items>
</imageOne>
</items>
</imageOnePanel>
<imageTwoPanel
jcr:primaryType="cq:Panel"
title="Image Two Panel">
<items jcr:primaryType="cq:WidgetCollection">
<imageTwo
jcr:primaryType="cq:Widget"
border="true"
ddGroups="[media]"
fileNameParameter="./imageTwo/fileName"
fileReferenceParameter="./imageTwoFileReference"
height="300"
hideLabel="true"
name="./imageTwo/file"
xtype="html5smartimage">
<items jcr:primaryType="cq:WidgetCollection">
<resType
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./imageTwo/sling:resourceType"
value="foundation/components/image"
xtype="hidden"/>
</items>
</imageTwo>
</items>
</imageTwoPanel>
</items>
</items>
Reusing code from the dialog & not giving unique properties might have caused you issues with adding a second image, though I'm not 100% from the error you're seeing.
Related
I was developing touch UI component. Below is what i tried and worked at some extent. Below is dialog.xml
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/tabs"
type="nav"/>
<items jcr:primaryType="nt:unstructured">
<herotext
jcr:primaryType="nt:unstructured"
jcr:title="Hero Text Properties"
sling:resourceType="granite/ui/components/foundation/section">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<myradiogroup
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/radiogroup"
fieldLabel="Select Fruit"
name="./fruit">
<items jcr:primaryType="nt:unstructured">
<option1
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/radio"
cq-msm-lockable="fruit"
renderReadOnly="{Boolean}true"
text="Apple"
value="apple"/>
<option2
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/radio"
cq-msm-lockable="fruit"
renderReadOnly="{Boolean}true"
text="Pear"
value="pear"/>
</items>
</myradiogroup>
</items>
</column>
</items>
</herotext>
</items>
</content>
After this I am able to render the radio selected value on the page. But having below issue.
1) Radio options are coming in vertical direction, but i want them in horizontal.
2) Radio Group Name not display, I want same like as fieldLabel & want to hide hide the border line.
3) When i reopen the dialog, radiobutton is not selected even if the selected value stored in JCR during last submit.
Thanks
For getting the Radio Buttons in horizontal direction use following class as property with coral-RadioGroup--horizontal value. This is the OOTB class provided by AEM, you can also have your custom class to control layout and alignment
For displaying the Radio Button Group label use text property.
On opening the dialog, properties are populating fine. See if you have any other radiobuttongroup in same dialog with same name.
I am designing a dialog in which i want the radio buttons displayed horizontally and not vertically, so that appear in a single line. Any ideas how to achieve this.
Below is my dialog.xml.
<items
jcr:primaryType="cq:Widget"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1
jcr:primaryType="cq:Panel"
title="Slider">
<items jcr:primaryType="cq:WidgetCollection">
<typeconfigs
jcr:primaryType="cq:Widget"
fieldLabel="Select Videos"
name="./options"
xtype="customconfigmultifield">
<fieldConfigs jcr:primaryType="cq:WidgetCollection">
<gridlayout
jcr:primaryType="cq:Widget"
itemId="dispotions"
name="selcttab"
type="radio"
xtype="selection">
<options jcr:primaryType="cq:WidgetCollection">
<grid1
jcr:primaryType="nt:unstructured"
text="grid1"
value="grid1"/>
<grid2
jcr:primaryType="nt:unstructured"
text="grid2"
value="grid2"/>
<grid3
jcr:primaryType="nt:unstructured"
text="grid3"
value="grid3"/>
<grid4
jcr:primaryType="nt:unstructured"
text="grid4"
value="grid4"/>
</options>
</gridlayout>
</fieldConfigs>
<limit
jcr:primaryType="nt:unstructured"
maxVal="{Long}6"/>
</typeconfigs>
</items>
</tab1>
</items>
Thanks
You can try using ExtJS Layouts for the same. There are various ways of configuring the same, one of which could be using an hbox layout as shown below.
Use the layout config available for Selection Widget and set its value to hbox. Then use the optionsConfig to set the width that applies to each radio box. Since the optionsConfig accepts an object, create it is a child node of your selection and then set the required styles.
Sample Dialog Structure shown below.
<gridlayout
jcr:primaryType="cq:Widget"
itemId="dispotions"
name="selcttab"
type="radio"
xtype="selection"
layout="hbox">
<options jcr:primaryType="cq:WidgetCollection">
<grid1
jcr:primaryType="nt:unstructured"
text="grid1"
value="grid1"/>
<grid2
jcr:primaryType="nt:unstructured"
text="grid2"
value="grid2"/>
<grid3
jcr:primaryType="nt:unstructured"
text="grid3"
value="grid3"/>
<grid4
jcr:primaryType="nt:unstructured"
text="grid4"
value="grid4"/>
</options>
<optionsConfig
jcr:primaryType="nt:unstructured"
width="60" />
</gridlayout>
This solution works in general, however, i notice that there is a custom widget customconfigmultifield defined under which you are configuring a selection field. So you might need to tweak your styles accordingly.
I am trying to add different custom page properties for different templates in Adobe CQ5. I have tried to to over-ride the default page component in apps/project-name/components and customized the page-properties in the dialog; but it changed the page-properties for all the pages. Is there a way using which we can get different custom page properties for different templates in the page properties dialog ?
Well there is one clumsy way.
The xtype cqinclude can help. It has a path attribute that points to a dialog-resource that is to be included (in JSON format). That path is to be requested via Ajax. So you can create a servlet that returns dialog's elements in JSON format depending on referer's template. Then use it in your basic template's dialog.xml:
<?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"
stateful="false"
xtype="dialog">
<items jcr:primaryType="cq:WidgetCollection">
<tabs jcr:primaryType="cq:TabPanel">
<items jcr:primaryType="cq:WidgetCollection">
<basic
jcr:primaryType="cq:Widget"
path="/libs/foundation/components/page/tab_basic.infinity.json"
xtype="cqinclude"/>
<advanced
jcr:primaryType="cq:Widget"
path="/libs/foundation/components/page/tab_advanced.infinity.json"
xtype="cqinclude"/>
<image
jcr:primaryType="cq:Widget"
path="/libs/foundation/components/page/tab_image.infinity.json"
xtype="cqinclude"/>
<cloudservices
jcr:primaryType="cq:Widget"
path="/libs/foundation/components/page/tab_cloudservices.infinity.json"
xtype="cqinclude"/>
<blueprint
jcr:primaryType="cq:Widget"
path="/libs/foundation/components/page/tab_blueprint.infinity.json"
xtype="cqinclude"/>
<livecopy
jcr:primaryType="cq:Widget"
path="/libs/foundation/components/page/tab_livecopy.infinity.json"
xtype="cqinclude"/>
<custom
jcr:primaryType="cq:Widget"
path="/services/MyServlet"
xtype="cqinclude"/>
</items>
</tabs>
</items>
</jcr:root>
But I advise you to use it only if there is no other choice.
Templates alone are not enough to have separate page properties. You'll need different page components where you can define the dialog. You can still have one base component and the exact same JSPs for the rendering and just override the dialog, if you use the inheritance (sling:resourceSuperType).
I need to create a component (say componentA) whose aim is to allow a user to add a variable number of components (choosing from componentB and componentC). So componentA is like a parsys which contains others components.
I'm using a multifieldpanel to create a component's dialog with a user controlled number of field. Something like this:
The problem is when I try to eliminate one of the elements added directly from the dialog of componentA: the element is effectively eliminated from the dialog but it actually remains inside the CRX.
My CRX is something like:
componentA
componentASon_0
componentASon_1
If I remove the component (componentASon_0 or componentASon_1) with a "right-click and delete" it works properly.
Any advice?
Here a snippet of the dialog relative to the componentA:
<tabMain
jcr:primaryType="cq:Widget"
title="myPanelTitle"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<settings jcr:primaryType="cq:Widget"
fieldLabel="Payment Settings"
fieldDescription="Click the '+' to add a new block"
name="./settings"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<component
jcr:primaryType="nt:unstructured"
defaultValue="Choose a component"
fieldLabel="Component"
type="select"
value=""
key="componentType"
xtype="selection">
<options jcr:primaryType="cq:WidgetCollection">
<componentB
jcr:primaryType="nt:unstructured"
text="ComponentB"
value="/apps/project/components/commons/componentB"/>
<componentC
jcr:primaryType="nt:unstructured"
text="ComponentC"
value="/apps/project/components/commons/componentC"/>
</options>
</component>
</items>
</fieldConfig>
</settings>
</items>
</tabMain>
The out of the box (OOTB) page properties dialog in Adobe Experience Manager (AEM) (CQ5) provides an Image tab. I would like to add a couple more images to the dialog, but I don't want to create a separate tab for each one.
For instance, is there a way to include an image on the "Advanced" tab within a dialogfielset? I tried this, but it does not seem to render properly.
One thing I am considering is to extend the slideshow xtype and each image would be a separate "slide"
Are there better approaches?
It's possible to have multiple smartimage xtypes on a tab!
Widgets API document for smartimage:
Note that the component is mainly designed for use on a separate
dialog tab. You may use the component inside a
CQ.Ext.layout.FormLayout optionally if you provide a suitable height
setting.
Here are codes for 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"
height="{Long}600"
title="dialog"
xtype="dialog">
<items
jcr:primaryType="cq:Widget"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<panel
jcr:primaryType="cq:Panel"
title="Panel with two Images">
<items jcr:primaryType="cq:WidgetCollection">
<firstimage
jcr:primaryType="cq:Widget"
cropParameter="./firstimage/imageCrop"
ddGroups="[media]"
fieldLabel="first image field"
fileNameParameter="./firstimage/fileName"
fileReferenceParameter="./firstimage/fileReference"
height="{Long}200"
name="./firstimage/file"
rotateParameter="./firstimage/imageRotate"
title="First Image"
width="{Long}200"
xtype="html5smartimage"/>
<secondimage
jcr:primaryType="cq:Widget"
cropParameter="./secondimage/imageCrop"
ddGroups="[media]"
fieldLabel="second image field"
fileNameParameter="./secondimage/fileName"
fileReferenceParameter="./secondimage/fileReference"
height="{Long}200"
name="./secondimage/file"
rotateParameter="./secondimage/imageRotate"
title="secondimage"
width="{Long}200"
xtype="html5smartimage"/>
</items>
</panel>
</items>
</items>
</jcr:root>
And the following is the result: