您需要将此配置放在设计的 .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 中,但实际上并未应用)。
所以您的第一个问题的答案是,您必须将这些设置放入您的设计中。关于你的第二个问题,不,除了使用模板的正确设计路径之外,你不需要配置任何其他内容。