Restrict the components in AEM 5.6.1
Asked Answered
P

3

11

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?

Parris answered 24/4, 2014 at 16:50 Comment(0)
H
14

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.

Hebetude answered 25/4, 2014 at 8:35 Comment(3)
is there a way to limit how many components can be dropped into yourParsys? For example I want one and only one foundation/components/text to be droppable into it and nothing else.Valkyrie
No straightforward way that I've found. You might be able to overlay a JS file within the sidekick & do a check on insert? Or embed the component directly in the template with a check box to show/hide. To be honest though, these are the type of things that are more easily solved by editorial guidelines than development effort.Hebetude
@Behrang There is, but it requires either overriding the default parsys component OR implementing a request filter to delete excess nodes. The right way to handle that will really depend on the core business requirements.Sherilyn
L
0

You can set the allowed parents property for the component to restrict where a component is used e.g., allowedParents="[*/parsys]"

Lime answered 24/4, 2014 at 16:53 Comment(0)
F
0

The only way I can think to do this is to create a new parsys component that simply extends the existing one with sling:resourceSuperType. Then use allowedParents property on the component and specify your specific parsys. Finally use your specific parsys on the page template in question. I have not tried this as of yet, but have kept the idea in my back pocket. Let me know if it works.

Fit answered 26/4, 2014 at 10:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.