【发布时间】:2014-04-24 16:50:05
【问题描述】:
如何限制 AEM 5.6.1 中可在模板的特定 parsys 中使用的组件,而无需在设计模式中选择它们?
【问题讨论】:
标签: aem
如何限制 AEM 5.6.1 中可在模板的特定 parsys 中使用的组件,而无需在设计模式中选择它们?
【问题讨论】:
标签: aem
在 CRXDE 中,在 /etc/designs/[your design]/jcr:content 下,您可以定义节点来表示您的每个模板及其段落,并列出每个模板允许的组件。
格式是每个模板的一个节点,其中包含每个 parsys 的一个节点(都是[nt:unstructured])。
然后,parsys 节点具有定义为 foundation/components/parsys 的 sling:resourceType 和 String[] 的 components 属性。例如,查看 Geometrixx 的定义方式:http://localhost:4502/crx/de/index.jsp#/etc/designs/geometrixx/jcr%3Acontent/contentpage/par
然后您可以通过 VLT 提取此文件,该文件将作为 .content.xml 文件存储在 etc/designs/[your design] 下。
或者,您也可以手动创建该文件。例如。以下将“您的设计”定义为允许“yourTemplate”的“yourParsys”段落中的默认“文本”和“图像”组件。
<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:template="/libs/wcm/core/templates/designpage"
jcr:primaryType="cq:PageContent"
jcr:title="You Design">
<yourTemplate jcr:primaryType="nt:unstructured">
<yourParsys
jcr:primaryType="nt:unstructured"
sling:resourceType="foundation/components/parsys"
components="[foundation/components/text,foundation/components/image]"/>
</yourTemplate>
</jcr:content>
</jcr:root>
这允许您跨实例移动此文件(例如,在部署 CRX 包时),这样您就不必单独配置环境以及允许哪些组件在哪里也可以通过版本控制进行管理。
【讨论】:
yourParsys 的组件数量?例如,我希望只有一个 foundation/components/text 可以放入其中,仅此而已。
您可以设置组件的 allowed parents 属性以限制组件的使用位置,例如allowedParents="[*/parsys]"
【讨论】:
我能想到的唯一方法是创建一个新的 parsys 组件,该组件只需使用 sling:resourceSuperType 扩展现有组件。然后在组件上使用 allowedParents 属性并指定您的特定 parsys。最后在有问题的页面模板上使用您的特定 parsys。我还没有尝试过这个,但我一直把这个想法放在我的后兜里。让我知道它是否有效。
【讨论】: