Monday, July 20, 2015

AEM 6 | How to add default properties for components

Use Case 1 : We usually bind the components with Component group to help authors while authoring the page. But once components are dragged dropped on the page , its difficult to track them back to which component group it belongs (apart from getting the resourcetype and then check). 

Use Case 2 : sometimes we need certain properties should be set by default when component is dragged dropped on the page .

AEM provides OOTB feature : 
  1. Lets assume your component is located at "/apps/mysample/components/test"
  2. Add the node "cq:template" of type "nt:unstructured" to the component.
  3. Add <propertyname> and its <value> to the "cq:template" node.
  4. Now wheresoever this component will be placed (on any page) , following properties (set in step 2) will be part of the component by default and we can get from them from page properties.

No comments:

Post a Comment