Expand my Community achievements bar.

SOLVED

Editable template association with Policies

Avatar

Community Advisor

For the static template, the design is stored at /etc/designs/<my-site>/jcr:content/<page-component-name>/<component-name> (if the page has a design path of /etc/designs/<my-site>) or/etc/designs/default/jcr:content/<page-component-name>/<component-name>

For editable template, design is stored at /conf/<your-project>/settings/wcm/policies.

So, In case of editable templates,only one template specific configuration(i.e. policies) per template can be there.

But, it is not the case with the static template, where more than one template-specific configurations (i.e. provide one separate design) can be associated with the template.

Template Name

Static Template

Editable Template

Design

T1/etc/designs/<site-name>/fr/jcr:content/landingpage/conf/<project-name>/settings/wcm/policies/t1/etc/design/<project-name>/fr
T1/etc/designs/<site-name>/us/jcr:content/landingpage/conf/<project-name>/settings/wcm/policies/t1/etc/design/<project-name>/us

How the above use case can be solved for the Editable template, wherein I want more than 1 policies (or config)  per template depending on the designs.

1 Accepted Solution

Avatar

Correct answer by
Employee

When you create an editable template directory. You create a scope for templating. There, you will have a local list of policies. One can create as many policies as they want. Content Policies are meant to be reusable and portable. The content policy mechanism is leveraging the Conf Manager. This means that the policies can be located at many different places such as follows:

  • /conf/<my-template-folder>/settings/wcm/policies (project level)
  • /conf/global/settings/wcm/policies (global level)
  • /apps/settings/wcm/policies (customer level)
  • /libs/settings/wcm/policies (AEM Private level)

To have access to all the policies located under the previous paths at once, one must set the merge list property on the jcr:content under the local policies node such as:

/conf/<my-template-folder>/settings/wcm/policies/jcr:content/mergeList{Boolean}=true

tl;dr

The merging logic of the Conf Manager is as follows:

  1. going from the most unspecific config to the most specific
  2. start with the original set (list)
  3. then for each set (same config item name) from the different configs
  4. look at the currently merged set (a) and the next one (b), item by item
  5. and decide what happens with the item, based on its node/page name:
    1. new item in (b) will be added to the set (a)
    2. existing item (a) will be replaced by same name item (b) if that one has a jcr:content child
    3. existing item (a) will get removed if there is a same name item in (b) without any jcr:content child

View solution in original post

10 Replies

Avatar

Level 10

For information in this subject - see the AEM docs here:

Page Templates - Editable

Avatar

Community Advisor

Hi smacdonald2008 ,

The Page Templates - Editableoes not tell how we solve this issue.

Regards,

Varun Rawat

Avatar

Level 10

TO clarify - you believe there is missing information from the docs?

Avatar

Level 10

We are looking into this as well.

Avatar

Community Advisor

smacdonald2008 ,

Let me know when I can get the update on the above.

Avatar

Correct answer by
Employee

When you create an editable template directory. You create a scope for templating. There, you will have a local list of policies. One can create as many policies as they want. Content Policies are meant to be reusable and portable. The content policy mechanism is leveraging the Conf Manager. This means that the policies can be located at many different places such as follows:

  • /conf/<my-template-folder>/settings/wcm/policies (project level)
  • /conf/global/settings/wcm/policies (global level)
  • /apps/settings/wcm/policies (customer level)
  • /libs/settings/wcm/policies (AEM Private level)

To have access to all the policies located under the previous paths at once, one must set the merge list property on the jcr:content under the local policies node such as:

/conf/<my-template-folder>/settings/wcm/policies/jcr:content/mergeList{Boolean}=true

tl;dr

The merging logic of the Conf Manager is as follows:

  1. going from the most unspecific config to the most specific
  2. start with the original set (list)
  3. then for each set (same config item name) from the different configs
  4. look at the currently merged set (a) and the next one (b), item by item
  5. and decide what happens with the item, based on its node/page name:
    1. new item in (b) will be added to the set (a)
    2. existing item (a) will be replaced by same name item (b) if that one has a jcr:content child
    3. existing item (a) will get removed if there is a same name item in (b) without any jcr:content child

Avatar

Level 1

Is this accurate?

 

We've tried to merge in policies from `/conf/global/settings/wcm/policies` in our site specific config (`/conf/<site>/settings/wcm/policies`) with `mergeList` set to true on the jcr:content node, and this evidently doesn't work.

 

We've also tried to merge in policies from `/apps/settings/wcm/policies` in our site specific config with `mergeList` set to true. This works initially, but once an author attempts to add a new policy, an exception is thrown and error popup is displayed:

 

        org.apache.sling.api.resource.PersistenceException: Unable to create node at /conf/<site>/settings/wcm/policies/wci/components

 

After the exception is thrown, all policies from `/apps/settings/wcm/policies` are no longer merged into the site's policies.

Avatar

Community Advisor

Hi patrickf14763699 ,

Can i associate different policies for the same Template based on different designs?

Avatar

Employee

Hi rawvarun,

No, the content policy is basically the equivalent of the design. Your are going to have one content policy where you previously had a design node with a static template.

Avatar

Level 1

Based on locations specific site, i want to add a policy to the common template which already has common components.

Can this be done by adding multiple cq:policy be added to the template?