Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restrict the components in AEM 5.6.1

Tags:

aem

How can I restrict the components in AEM 5.6.1 that can be used in a particular parsys of a template with out selecting them in the design mode?

like image 829
Morais Avatar asked Apr 24 '14 16:04

Morais


People also ask

How do I restrict a template from showing in a certain path?

In order to allow a template to be created under a certain path, there is a flag allowedPaths that receives a regex. So, if I want my template "test" to appear only under /content/www/xx/xx/test-templates and child elements, I can do this: /content/www/. */.

What is cq template?

cq:template has the type nt:unstructured , it allows you to define a complex node with a set of properties and children. It's a node you create as a child of your component definition. This content will be used as default values whenever you drop a new instance of the component from the sidekick.

What does Super Type define when creating a component?

Sling resource super type It means we are leveraging Core Components (discussed here). By using sling:resourceSuperType property we are inheriting the properties of the core component's page component in our page component.


1 Answers

In CRXDE, under /etc/designs/[your design]/jcr:content, you can define nodes to represent each of your templates & their paragraphs & list the allowed components for each.

The format is a node for each template that contains a node for each parsys (both [nt:unstructured]).

The parsys node then has a sling:resourceType defined of foundation/components/parsys and a components property of String[]. For an example, check out how the Geometrixx one is defined: http://localhost:4502/crx/de/index.jsp#/etc/designs/geometrixx/jcr%3Acontent/contentpage/par

You could then extract this via VLT, which gets stored as a .content.xml file under etc/designs/[your design].

Alternatively, you can create that file by hand, too. E.g. the following would define 'Your Design' as allowing default "text" and "image" components on the "yourParsys" paragraph of "yourTemplate".

<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:template="/libs/wcm/core/templates/designpage"
      jcr:primaryType="cq:PageContent"
      jcr:title="You Design">
        <yourTemplate jcr:primaryType="nt:unstructured">
            <yourParsys
              jcr:primaryType="nt:unstructured"
              sling:resourceType="foundation/components/parsys"
              components="[foundation/components/text,foundation/components/image]"/>
        </yourTemplate>
    </jcr:content> 
</jcr:root>

This allows you to move this file across instances (e.g when deploying a CRX package) so that you don't have to configure environments individually & which components are allowed where can also be managed by version control.

like image 172
anotherdave Avatar answered Oct 10 '22 19:10

anotherdave