One way of changing the default text all over the place is editing/overriding the script in /libs/cq/gui/components/authoring/clientlibs/editor/js/model/Inspectable.js. It would change the text everywhere in the parsys. But, I wanted to customize this text for each component and it can be achieved with the following steps
Step 1: Override the parsys from the out of the box AEM to your apps folder ie wcm/foundation/components/parsys.
The new sightly component is placed in the /libs/wcm/foundation/components/parsys.
Step 2: Add the property "sling:resourceSuperType" and the value "wcm/foundation/components/parsys" at the component level or the .content.xml. The code will look like
<?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"
jcr:primaryType="cq:Component"
jcr:title="Paragraph System - Sightly"
jcr:description="Include components in a paragraph system."
allowedChildren="[*]"
componentGroup=".hidden"
sling:resourceSuperType="wcm/foundation/components/parsys"/>
Step 3: Select the newpar component folder inside this component and add the property sling:resourceType with the value "wcm/foundation/components/parsys/newpar". This code will look like
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Component"
jcr:title="New Paragraph - Sightly"
sling:resourceType="wcm/foundation/components/parsys/newpar"
componentGroup=".hidden"/>
Step 4: The default text can be set empty by making the following change. Open the parsys.html files change this line
<div data-sly-test="${!paragraph.columns && paragraph.resourceType && paragraph.cssClasses}" class="${paragraph.cssClasses}" data-sly-resource="${paragraph.resourcePath @ resourceType=paragraph.resourceType, decorationTagName=''}"></div> to
<div data-sly-test="${!paragraph.columns && paragraph.resourceType && paragraph.cssClasses}" class="cq-placeholder section" data-emptytext="" data-sly-resource="${paragraph.resourcePath @ resourceType=paragraph.resourceType, decorationTagName=''}"></div>
That's all required in the overridden/extended parsys component. Now, we need to add some code in our new components that includes the parsys.
Step 5: Create a new component and use the following code for adding the placeholder text is <div class="cq-placeholder section" data-emptytext="Your Custom Text"></div>
The sighlty code for including any component would be like <sly data-sly-resource="${'myComponents' @ resourceType='/apps/yourProject/parsys' }"></sly>
Note: the resourceType would point to the folder where our parsys component is created.
HI Ravi It is very good post . Just need to confirm, for me its working in touch UI and not for classic UI. SO do we need to do something more for classic UI ?
ReplyDeleteI think you can refer the iparsys in the
Delete/libs/wcm/foundation/components/iparsys. This component will work on both classic & touch UI. try doing the same changes to the iparsys component.
I would also be interessted in an working solution for ClassUI
ReplyDeleteHey Ravi!
ReplyDeleteI have taken the exact same steps as written here. Though it gets me a customized text for every parsys, but the parsys just doesn't move down when you drag-drop anything into it.
Can you help me with this?
Hi Karttik, Did you try adding P tag or Div tag before the parsys include code?
ReplyDeleteHey!
ReplyDeleteThis is how I have included my custom parsys:
<div class = "cq-placeholder section" data-emptytext = "My custom Text" data-sly-resource="${'par' @ resourceType='/apps/myProject/components/par/parsys'}"></div>
Am I doing anything wring here?
I was trying to zero-in on the exact reason behind the parsys getting fixed on a particular place. My take is that, the cq-placeholder class that we are using here makes it fixed.
Hi Kartik
ReplyDeleteWere you able to resolve this issue?
Hi Pardeep,
Deletedid you have any feedback?
I also faced a similar issue and after finding no suitable answers anywhere, decided to do my own solution and wrote a detailed blog entry explaining the steps.
ReplyDeleteYou can find all the relevant details here: -
https://scribcopia.wordpress.com/2017/08/13/customizing-text-within-parsys-touch-ui/
It worked, but i'm getting disabled parsys.
ReplyDeleteCan we customize height,width and position of parsys?
ReplyDelete