How to limit components in a template without design dialog | Community
Skip to main content
New Participant
October 16, 2015
Solved

How to limit components in a template without design dialog

  • October 16, 2015
  • 4 replies
  • 2651 views

Does anyone know how to define a list of components in a template, so when an author creates a page, author can only choose a components from the list?

I tried to put components property in my template called limit as below:

    <?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="Limit Template"
    jcr:description="Limit template with predefined components"
    allowedPaths="/content(/.*)?"
    ranking="{Long}2040">
    <jcr:content
        cq:designPath="/etc/designs/mysite"
        jcr:primaryType="cq:PageContent"
        components="[/apps/mysite/components/content/article,/apps/mysite/components/content/button,/apps/mysiten/components/content/image]"
        sling:resourceType="mysite/components/pages/limit">
     </jcr:content>
</jcr:root>

I see the components property and value in the /mysite/templates/limit/jcr:content. But when I create a page, I didn't see the predefined components. 

Thank you for your help.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Pawan-Gupta

Hello,

I think you are updating the property at template jcr:content (as jcr:primaryType shows cq:Template instead nt:unstructured)  node which is wrong location because template does not hold the design rules. if you want to update it programmetically then you should update it inside "/etc/designs/mysite/jcr:content" corresponding to your template name. Also remember to draw the correct hierarchy of parsys with proper name so that the rule can match correctly. For more details you can refer geometrixx site design rule heirarchy located at /etc/designs/geometrixx/jcr:content

 

Thanks,

Pawan

4 replies

crisr1
New Participant
May 14, 2016

I've used /etc/designs/app/jcr:content/template/parsys but it's not very satisfying. It has to match the template and content structure. So it matter what the parsys is named par, gridpar, col1, etc.  Though with Classic UI inheritance worked pretty well so that /etc/designs could be set on one base page, which could hold the config for the other pages with support for nesting and multiple parsys (without explicit configs for each in my experience). It does not work as well in Touch UI. In Touch UI I find it generates a lot of inadvertent 404's on hover for the exact /etc/designs/app/jcr:content node, but somehow it still has the inherited allowed components so authoring works anyway. Maybe I shouldn't say it, but Design Mode and this allowed components thing is my least favorite part of AEM.  

Based on https://helpx.adobe.com/experience-manager/kb/HowToDefineComponentListDynamically.html you might try to add a listener. For example in the page component edit config, which I think is probably not recommended. 

<?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:EditConfig" > <cq:listeners jcr:primaryType="cq:EditListenersConfig" updatecomponentlist="function(cell, allowed, componentList){ allowed.push('/libs/cq/tagging/components/tagcloud'); allowed.push('/libs/wcm/foundation/components/text');            allowed.push('wcm/foundation/components/title');
}"/> </jcr:root>
Pawan-Gupta
Pawan-GuptaAccepted solution
New Participant
October 16, 2015

Hello,

I think you are updating the property at template jcr:content (as jcr:primaryType shows cq:Template instead nt:unstructured)  node which is wrong location because template does not hold the design rules. if you want to update it programmetically then you should update it inside "/etc/designs/mysite/jcr:content" corresponding to your template name. Also remember to draw the correct hierarchy of parsys with proper name so that the rule can match correctly. For more details you can refer geometrixx site design rule heirarchy located at /etc/designs/geometrixx/jcr:content

 

Thanks,

Pawan

GK-007
New Participant
October 16, 2015
BigT168Author
New Participant
October 16, 2015

Thank you.

I did look at this option before posted my question. I was looking for alternative way to do it without modifying the file under the /etc/designs. Seems this is the only choice.