Stan
Stan

Reputation: 1308

cq:emptyText is not working in Adobe CQ5.5

I'm developing a custom container component in Adobe CQ5.5 and I'd like to have a custom message as a placeholder instead of the default "Drag components or assets here".

What I found out until now is that I have to add cq:emptyText="My custom placeholder message". Probably I'm missing something as this property gets completely ignored. Here's my component's folder structrure:

According to Adobe's official tutorials and also this wonderful tutorial for building an Accordion container, the cq:emptyText should go into the _cq_editConfig.xml file:

<?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"
    cq:actions="[edit]"
    cq:dialogMode="floating"
    cq:emptyText="Drag My Custom components here"
    jcr:primaryType="cq:EditConfig">
    <cq:listeners
        jcr:primaryType="cq:EditListenersConfig"
        afteredit="REFRESH_PAGE"/>
</jcr:root>

Unfortunately, even with cq:emptyText included I'm still seeing the default placeholder text.

Any help will be highly appreciated!

Thanks!

Stan.


UPDATE:

After Tomek's suggestions, I still get "Drag components or assets here" instead of my custom message so I'm still looking for an answer. My component's file structure now looks like this: - [clientlib] - [new] ---- .content.xml ---- _cq_editConfig.xml - .content.xml - _cq_editConfig.xml - dialog.xml - tabContainer.jsp

.content.xml

<?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"
    cq:isContainer="{Boolean}true"
    jcr:primaryType="cq:Component"
    jcr:title="Tab Container"
    jcr:description="Container component for tab pages"
    sling:resourceSuperType="foundation/components/parsys"
    componentGroup="MyComponents"/>

_cq_editConfig.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"
    cq:actions="[edit]"
    cq:dialogMode="floating"
    jcr:primaryType="cq:EditConfig">
    <cq:listeners
        jcr:primaryType="cq:EditListenersConfig"
        afteredit="REFRESH_PAGE"/>
</jcr:root>

new/.content.xml

<?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"
    sling:resourceType="foundation/components/parsys/new"
    componentGroup=".hidden"/>

new/_cq_editConfig.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"
    cq:actions="[_clear,insert]"
    cq:emptyText="Drag My Custom components here"
    jcr:primaryType="cq:EditConfig" />

Upvotes: 3

Views: 2665

Answers (2)

Przemek Lewicki
Przemek Lewicki

Reputation: 41

As you're implementing parsys, you need following structure, as Tomek Rękawek suggested:

.content.xml (the important part here is the resourceSuperType)

<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"
    cq:isContainer="{Boolean}true"
    jcr:primaryType="cq:Component"
    jcr:title="Your title"
    sling:resourceSuperType="foundation/components/parsys" />

new/.content.xml

<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"
    sling:resourceType="foundation/components/parsys/new"
    componentGroup=".hidden"/>

new/_cq_editConfig.xml (this is where you would want to set the cq:emptyText attribute)

<?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"
    cq:actions="[_clear,insert]"
    cq:emptyText="Drag My Custom components here"
    jcr:primaryType="cq:EditConfig"/>

At this moment I was not getting the "Drag My Custom components here" text on the component placeholder. What did the trick for me was to create new/new.jsp with following content:

new/new.jsp

<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"
%><%@include file="/libs/foundation/global.jsp"
%><%@ page session="false" import="
    com.day.cq.wcm.api.components.EditContext" %><%

    editContext.getEditConfig().setEmpty(true);
%>

Then I was able to see the empty text I set in new/_cq_editConfig.xml. I've tested this on CQ5.6.

Hope this helps.

Upvotes: 4

Tomek Rękawek
Tomek Rękawek

Reputation: 9304

This container is usually called paragraph system or parsys. You should have structure like this:

.content.xml

<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"
    cq:isContainer="{Boolean}true"
    jcr:primaryType="cq:Component"
    jcr:title="Your title"
    sling:resourceSuperType="foundation/components/parsys" />

new/.content.xml

<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"
    sling:resourceType="foundation/components/parsys/new"
    componentGroup=".hidden"/>

new/_cq_editConfig.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"
    cq:actions="[_clear,insert]"
    cq:emptyText="Drag My Custom components here"
    jcr:primaryType="cq:EditConfig"/>

So, you need to create new subdirectory to your component and the property should be added to the file new/_cq_editConfig.xml.

Upvotes: 2

Related Questions