AEM CQ允许模板中的父母和allowedChildren属性

时间:2015-10-05 09:38:46

标签: xml cq5

我需要创建以下模型页面(在localhost:4502 / siteadmin中):

Basepage
    |
    Homepage
        |
        Contentpage1
             |
             Contentpage2

基页 - 主页面,只能创建主页

基页模板.context.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"
jcr:primaryType="cq:Template"
jcr:title="Base site"
jcr:description=""
allowedPaths="[/content]"
ranking="{Long}100">
<jcr:content
    cq:designPath="/etc/designs/basesite"
    jcr:primaryType="cq:PageContent"
    cq:allowedTemplates="[/apps/powerade/templates/homepage]"
    sling:resourceType="foundation/components/redirect"/>
</jcr:root>

主页 - 可以创建任何页面(基页除外)但只有主页可以创建内容页

主页模板.context.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"
jcr:primaryType="cq:Template"
jcr:title="Homepage"
jcr:description="Homepage"
ranking="{Long}100">
<jcr:content
    jcr:primaryType="cq:PageContent"
    cq:allowedTemplates="[/apps/powerade/templates/.*]"
    sling:resourceType="powerade/pages/homepage"/>
</jcr:root>

Contentpage - 只能在首页或内容网页上创建,而contentpage只能创建contentpages

contentpage template .context.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"
jcr:primaryType="cq:Template"
jcr:title="Contentpage"
jcr:description="Contentpage"
ranking="{Long}99"
allowedParents="[/apps/powerade/templates/homepage, /apps/powerade/templates/contentpage]"
allowedChildren="[/apps/powerade/templates/contentpage]">
<jcr:content
    jcr:primaryType="cq:PageContent"
    cq:allowedTemplates="[/apps/powerade/templates/.*]"
    sling:resourceType="powerade/pages/contentpage"/>
</jcr:root>

我试图借助参数allowedParents和allowedChildren来实现这些要求,但不幸的是它不起作用

Contentpage看不到模板内容页面(无法创建Contentpage2): http://i.stack.imgur.com/quHN4.jpg

我做错了什么?

1 个答案:

答案 0 :(得分:2)

这是一个工作版本!但我们必须小心不要放置空间

allowedParents="[/apps/powerade/templates/homepage, /apps/powerade/templates/contentpage]" (don't work)

allowedParents="[/apps/powerade/templates/homepage,/apps/powerade/templates/contentpage]" (works!)