Hello,
I am currently struggling with defining policies on my code using the .content.xml under wcm/policies. For example I have a Section Container component that has a responsivegrid inside its HTML. My idea is to only allow the components group "Content" in there, so in my policies I added the following snippet:
<section-container jcr:primaryType="nt:unstructured">
<policy_1595870812979
jcr:primaryType="nt:unstructured"
jcr:title="Section Container"
sling:resourceType="wcm/core/components/policy/policy"
components="group:KG AEM Commons - Content">
<jcr:content jcr:primaryType="nt:unstructured"/>
</policy_1595870812979>
</section-container>
But when I do a clean install with the command mvn clean install -PautoInstallPackage and I check my policies the group was not added correctly, meaning I have to do it manually, as shown below. This is particular annoying because after each install my policies reset so I have to do this again.
Could it be the fault of my filters file? For the content module I define my filters as:
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="/conf/kg-commons" mode="update"/>
<filter root="/content/kg-commons" mode="merge"/>
<filter root="/content/dam/kg-commons" mode="merge"/>
<filter root="/content/cq:tags/kg-commons" mode="merge"/>
<filter root="/content/campaigns" mode="merge"/>
<filter root="/content/experience-fragments/kg-commons" mode="merge"/>
<filter root="/conf/kg-commons/settings/wcm/segments" mode="merge"/>
<filter root="/conf/kg-commons/settings/wcm/policies/.content.xml" mode="merge"/>
</workspaceFilter>
Views
Replies
Total Likes
Hi @Jeanmaradiaga ,
Filters might be the issue, please try changing the filter mode of last filter to update/replace instead of merge as it won't modify the existing node.
Hello @Kishore_Kumar_ thanks for the reply. I tried updating the last filter to update and then replace but it didn't seem to work. When installing my template still has an empty policy
Hi,
you can check my project for reference
https://github.com/arunpatidar02/aemaacs-aemlab/tree/master/ui.content/src/main/content
Hi @arunpatidar ,
Thanks for the reference it has been very helpful, unfortunately it still not works for me. I am wondering how can my policy know that I want my Section Container to allow all the components in the KG AEM Commons - Content group.
For example this is my section container, which contains a responsivegrid inside
.... <sly data-sly-resource="${resource @ resourceType='wcm/foundation/components/responsivegrid'}"></sly> ....
<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" cq:icon="panel" jcr:description="Basic layout component" jcr:primaryType="cq:Component" jcr:title="Section Container" sling:resourceSuperType="core/wcm/components/container/v1/container" componentGroup="KG AEM Commons - Full Width"/>
Then I define the policy, just like you did in your project
<section-container jcr:primaryType="nt:unstructured"> <policy_1595870812979 jcr:primaryType="nt:unstructured" jcr:title="Section Container" sling:resourceType="wcm/core/components/policy/policy" components="[group:KG AEM Commons - Content]"> <jcr:content jcr:primaryType="nt:unstructured"/> </policy_1595870812979> </section-container>
But on a normal content page when I add a Section Container and try to add anything like a text or button that belongs to the Content group I only see this
I know I can manually add it via the Template Editor but my code should work, it doesn't seem to have anything wrong at a a glance.
Hi,
You have defined the policy but you need to use this policy inside your template as well.
for e.g. I am using teaser policy
Policy defintaion
Used within the template https://github.com/arunpatidar02/aemaacs-aemlab/blob/9adb6f83726db2dd78a462428034207323f2290a/ui.con...
In your case you may have to either defined or use policy with nested wcm resource type like below
<section-container jcr:primaryType="nt:unstructured"> <wcm> <foundation> <components> <responsivegrid> <policy_1595870812979 jcr:primaryType="nt:unstructured" jcr:title="Section Container" sling:resourceType="wcm/core/components/policy/policy" components="[group:KG AEM Commons - Content]"> <jcr:content jcr:primaryType="nt:unstructured"/> </policy_1595870812979> </responsivegrid> </components> </foundation> </wcm> </section-container>
Views
Like
Replies
Views
Likes
Replies