如何将模板 content.xml 文件中的 2 个组件包装在 div 中?
How to wrap 2 components in a div from the template content.xml file?
我有两个组件应该在 cq 模板中配置,在 content.xml 文件中(在 jcr:content 节点中)。
我的模板没有页面组件,所以我不能这样做:
<div class="wrapper_div">
<cq:include resourceType="/my/first/component"/>
<cq:include resourceType="/my/second/component"/>
</div>
有没有办法从 content.xml 中定义 div 容器?
可以有一个技巧,您可以将下面的内容添加到模板的 content.xml 文件中。
<jcr:content
jcr:primaryType="cq:PageContent"
sling:resourceType="path/of/page/page-component">
<par
jcr:primaryType="nt:unstructured"
sling:resourceType="foundation/components/parsys">
<simple
jcr:lastModified="{Date}2015-05-05T12:16:19.895+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="path/components/content/component1"/>
<simple1
jcr:lastModified="{Date}2015-05-05T12:16:19.895+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="path/components/content/component2"/>
</par>
</jcr:content>
</jcr:root>
这将使用此模板为页面创建内容节点,但要完成这项工作,您必须在渲染页面组件中包含 parsys path/of/page/page-component
例如<cq:include path="par" resourceType="foundation/components/parsys" />
还有一些其他方法,例如在您的页面组件下添加 cq:template 的节点以预填充组件。
希望这会有所帮助。
我有两个组件应该在 cq 模板中配置,在 content.xml 文件中(在 jcr:content 节点中)。 我的模板没有页面组件,所以我不能这样做:
<div class="wrapper_div">
<cq:include resourceType="/my/first/component"/>
<cq:include resourceType="/my/second/component"/>
</div>
有没有办法从 content.xml 中定义 div 容器?
可以有一个技巧,您可以将下面的内容添加到模板的 content.xml 文件中。
<jcr:content
jcr:primaryType="cq:PageContent"
sling:resourceType="path/of/page/page-component">
<par
jcr:primaryType="nt:unstructured"
sling:resourceType="foundation/components/parsys">
<simple
jcr:lastModified="{Date}2015-05-05T12:16:19.895+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="path/components/content/component1"/>
<simple1
jcr:lastModified="{Date}2015-05-05T12:16:19.895+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="path/components/content/component2"/>
</par>
</jcr:content>
</jcr:root>
这将使用此模板为页面创建内容节点,但要完成这项工作,您必须在渲染页面组件中包含 parsys path/of/page/page-component
例如<cq:include path="par" resourceType="foundation/components/parsys" />
还有一些其他方法,例如在您的页面组件下添加 cq:template 的节点以预填充组件。
希望这会有所帮助。