【问题标题】:How to use cq:editConfig Property in AEM 6.0如何在 AEM 6.0 中使用 cq:editConfig 属性
【发布时间】:2019-01-14 20:50:24
【问题描述】:

在 AEM 6.0 中,我有一个组件,它有一个文本字段和一个视频文件上传器。我想从内容查找器中启用此视频的拖放功能。我使用对话框的正常上传工作正常,但这种拖放不起作用。我搜索并发现我可以通过使用 cq:editConfig 来做到这一点。有人能告诉我该怎么做吗?

【问题讨论】:

    标签: aem


    【解决方案1】:

    cq:dropTargets 定义为cq:editConfig 节点的子节点,以配置可以接受来自内容查找器资产的拖放的拖放目标列表。

    在您的情况下,对于视频,您可以参考foundation/components/video,其编辑配置如下所示。

    <cq:editConfig jcr:primaryType="cq:EditConfig" cq:layout="editbar">
        <cq:dropTargets jcr:primaryType="nt:unstructured">
            <video jcr:primaryType="cq:DropTargetConfig" propertyName="./asset">
                <parameters jcr:primaryType="nt:unstructured" 
                    sling:resourceType="foundation/components/video"/>
            </video>
        </cq:dropTargets>
    </cq:editConfig>
    

    还要确保在用于视频文件上传组件的html5smartfile 小部件上指定ddGroupsddAccept 属性。

    请参阅Configuring the Edit Behaviour of a component 以获取有关配置编辑配置及其子节点的更多信息。

    【讨论】:

    • 你能不能告诉你从哪里得到 cq 属性的这个 xml 表示。我仍在使用 CRXDe 结构。
    • 您可以使用节点路径的 .xml 扩展名获取任何节点的 XML 表示,即 http://localhost:4502/libs/foundation/components/video/cq:editConfig.xml 将为您提供上述 XML。同样,您可以使用 .json 扩展来获取相同的 JSON 表示。但是,JSON 表示将只包含当前节点属性而不是整个子节点,在这种情况下使用 infinity 选择器和 json 扩展。即http://localhost:4502/libs/foundation/components/video/cq:editConfig.infinity.json
    【解决方案2】:

    您必须小心执行此操作,因为它可能会产生意外的副作用,即会将您的组件类型更改为放置目标中指定的类型。

    为避免这种情况发生,您可以使用以下格式区分组件类型和目标类型:

    <cq:dropTargets jcr:primaryType="nt:unstructured">
        <video
            jcr:primaryType="cq:DropTargetConfig"
            accept="[video/.*]"
            propertyName="./asset">
            <parameters
                jcr:primaryType="nt:unstructured"
                sling:resourceType="myfolder/components/videoandtext">
                <video
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="foundation/components/video"
                    />
            </parameters>
        </video>
    </cq:dropTargets>
    

    查看这里了解更多信息:Drop Target Issue

    【讨论】:

      猜你喜欢
      • 2016-09-03
      • 1970-01-01
      • 1970-01-01
      • 2018-09-05
      • 1970-01-01
      • 1970-01-01
      • 2018-06-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多