user2581831
user2581831

Reputation: 117

Avoid nested components in AEM 6

I have an AEM container component which just include the parsys where i can drag and drop any component other than same container component. Is there any way i can restrict this container component to be used inside "parsys of a container" but should be able to used in "parsys inside page".

This is done to avoid the nesting of container component inside the another container component.

Any pointers will be highly appreciated!!

Upvotes: 1

Views: 2200

Answers (1)

Jens
Jens

Reputation: 21500

You can achieve this by adding a design in /etc/designs/<your-project-name>.

The JCR structure would look something like this:

+-+ etc
  +-+ designs
    +-+ <your project> (cq:Page)
      +-+ jcr:content (nt:unstructured)
        +-+ <name of your page template> (nt:unstructured)
          +-+ parsys (nt:unstructured)
            +-+ <name of your container component>
              +-+ parsys (nt:unstructured)
                +-* components String[]

Most important is the property named components of type String[]. This is the list of components that is allowed to be placed in the parsys of your container component. The components in the list are identified by their sling:resourceType.

Example:

components=[/apps/<your-projectname>/components/<component-name>,...]

This mechanism gives you fine-grained control over which components are allowed on a page or in another component.

If you are not already using /etc/designs you probably will have to update your page templates and set cq:designPath to /etc/designs/<your-project-name>.

To see how this works you could have a look at the geometrixx design that you can find here /etc/designs/geometrixx/jcr:content.

Upvotes: 1

Related Questions