【问题标题】:Questions on the answer for "Limiting allowed components in a template in cq5"关于“在 cq5 中限制模板中允许的组件”答案的问题
【发布时间】:2015-05-21 17:25:02
【问题描述】:

我从这个链接中看到了 Alisneaky 的回答: Limiting allowed components in a template in cq5 但是我对 Alisneaky 提供的答案有疑问,他建议将以下内容放入模板中:

   <TEMPLATENAME jcr:primaryType="nt:unstructured">
       <content
           jcr:lastModified="{Date}2014-04-11T13:04:48.855+10:00"
           jcr:lastModifiedBy="admin"
           jcr:primaryType="nt:unstructured"
           sling:resourceType="/libs/foundation/components/parsys"
           components="[/libs/foundation/components/text,
                        /libs/foundation/components/textimage]">
       </content>
   </TEMPLATENAME>

我尝试将这些放在 /etc/designs/mysite 下的 .content.xml 中,但没有看到 Sidekick 中显示任何组件。但是,如果我打开设计对话框,我确实看到复选框与这些预定义组件一起被选中。

我也将这些行放在了我的模板中,这一次,我在 Sidekick 和设计对话框中都没有看到任何内容。

我的问题: 1.这些线放在哪里?在我的模板或 /etc/designs/mysite 下的 .content.xml 中

  1. 为了让这些预定义的组件列表显示在 Sidekick 中,我必须进行哪些配置? (我确实在页面属性中将 designPath 指向 /etc/designs/mysite)。

感谢您的帮助

【问题讨论】:

    标签: aem


    【解决方案1】:

    您需要将此配置放在设计的 .content.xml 下。因此,如果您必须遵循项目结构:

    ├── jcr_root
        ├── apps
        │   └── company
        │       └── project
        │           ├── components
        │           │   ├── component1
        │           │   └── component2
        │           │   └── component3
        │           ├── pages
        │           │   └── mypage
        │           └── templates
        │               └── mypage
        └── etc
            └── designs
                └── company
                    └── project
    

    假设,您的页面模板如下所示:

    <?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:Template"
        jcr:title="My page template title"
        jcr:description="My page template description"
        allowedPaths="[/content(/.*)?]">
        <jcr:content
            jcr:primaryType="cq:PageContent"
            sling:resourceType="company/project/pages/mypage"
            cq:designPath="/etc/designs/company/project">
            <content
                jcr:primaryType="nt:unstructured"
                sling:resourceType="foundation/components/parsys"/>   
        </jcr:content>
    </jcr:root>
    

    你可以在 /etc/designs/company/project/.content.xml 下的 .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" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
        jcr:primaryType="cq:Page">
        <jcr:content
            cq:doctype="HTML_5"
            jcr:primaryType="nt:unstructured"
            jcr:title="My website design"
            sling:resourceType="wcm/core/components/designer">
            <mypage jcr:primaryType="nt:unstructured">
                <content
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="foundation/components/parsys"
                    components="[/apps/company/project/components/component1,/apps/company/project/components/component2]">
                    <section jcr:primaryType="nt:unstructured"/>
                </content>
            </mypage>
        </jcr:content>
    </jcr:root>
    

    通过这种方式,您可以将组件 company/project/components/component1 和 company/project/components/component2(与您的示例相同的基础组件)拖放到具有基础/组件/parsys 类型的内容节点中。 但我建议您始终通过design mode 中的设计器进行更改,并使用包管理器导出生成的.content.xml。这种方式已被证明是对您的设计进行更改的最安全方式。即使您在 xml 中的更改是有效的并将它们部署到 cq,有时 cq 也会拒绝应用这些设置(正是您的情况,这些设置显示在 sidekick 中,但实际上并未应用)。

    所以您的第一个问题的答案是,您必须将这些设置放入您的设计中。关于你的第二个问题,不,除了使用模板的正确设计路径之外,你不需要配置任何其他内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多