【问题标题】:cq:emptyText is not working in Adobe CQ5.5cq:emptyText 在 Adob​​e CQ5.5 中不起作用
【发布时间】:2013-10-07 20:03:01
【问题描述】:

我正在 Adob​​e CQ5.5 中开发一个自定义容器组件,我希望使用自定义消息作为占位符,而不是默认的“将组件或资源拖到此处”。

到目前为止,我发现我必须添加 cq:emptyText="My custom placeholder message"。可能我错过了一些东西,因为这个属性被完全忽略了。这是我的组件的文件夹结构:

  • [客户端库]
  • .content.xml
  • _cq_editConfig.xml
  • dialog.xml
  • myContainer.jsp

根据Adobe's official tutorialsthis wonderful tutorial for building an Accordion container,cq:emptyText 应该进入 _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"
    cq:emptyText="Drag My Custom components here"
    jcr:primaryType="cq:EditConfig">
    <cq:listeners
        jcr:primaryType="cq:EditListenersConfig"
        afteredit="REFRESH_PAGE"/>
</jcr:root>

不幸的是,即使包含 cq:emptyText,我仍然会看到默认占位符文本。

任何帮助将不胜感激!

谢谢!

斯坦。


更新:

在 Tomek 的建议之后,我仍然收到“将组件或资产拖到此处”而不是我的自定义消息,因此我仍在寻找答案。我的组件的文件结构现在如下所示: - [客户端库] - [新的] ---- .content.xml ---- _cq_editConfig.xml - .content.xml - _cq_editConfig.xml - 对话框.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" />

【问题讨论】:

    标签: adobe components containers aem


    【解决方案1】:

    正如 Tomek Rękawek 建议的那样,在实施 parsys 时,您需要以下结构:

    .content.xml这里的重要部分是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这是您要设置 cq:emptyText 属性的地方

    <?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"/>
    

    此时我没有在组件占位符上看到“将我的自定义组件拖到此处”文本。我的诀窍是使用以下内容创建new/new.jsp

    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);
    %>
    

    然后我可以看到我在new/_cq_editConfig.xml 中设置的空文本。我已经在 CQ5.6 上测试过了。

    希望这会有所帮助。

    【讨论】:

    • 感谢您的回复!我添加了 new/new.jsp 但仍然没有效果:-(。我在 5.6.1 上运行,这意味着可能有一个设置可能需要打开。我使用的是完全相同的文件和你一样,但没有结果。
    • @stan,我正在运行 5.6.1 这个答案对我有用
    • 正如我所说,可能还有其他原因阻止我显示该文本,最终我停止尝试。
    【解决方案2】:

    这个容器通常被称为段落系统parsys。你应该有这样的结构:

    .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"/>
    

    因此,您需要为组件创建new 子目录,并将属性添加到文件new/_cq_editConfig.xml

    【讨论】:

    • 感谢托梅克的回复。我做了你建议的一切,但我仍然只看到默认的“将你的组件或资产拖到这里”。有关更多信息,请参阅上面的更新,我不能把所有东西都放在这里。
    猜你喜欢
    • 2014-07-18
    • 2011-05-12
    • 2022-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多