如何从模板content.xml文件中包装div中的2个组件?

时间:2015-05-04 14:28:41

标签: cq5

我有两个组件应该在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容器?

1 个答案:

答案 0 :(得分:0)

可以有一个技巧,您可以在下面添加到模板的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>

这将使用此模板为页面创建内容节点,但要使其工作,您必须在渲染页面组件path/of/page/page-component中包含解析,例如<cq:include path="par" resourceType="foundation/components/parsys" />

还有一些其他方法可以在页面组件下添加cq:template节点以预先填充组件。

希望这会有所帮助。