Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Updating component and template policies in code

Avatar

Level 4

I am having an issue with updating a specific component's policy. I have updated it in code, but when I deploy the code, the changes are not there.

 

I have a file /conf/project/settings/wcm/policies/.content.xml that includes all policies related to templates and components. Within it I have a custom component called hero-banner that I added a style called "half-height" to in code. I have also added the associated styles and the filter includes the entire root when deploying.

<filter root="/conf" mode="merge"/>
<cq:styleGroups jcr:primaryType="nt:unstructured">
<display-variation
cq:styleGroupLabel="Alternate Version"
jcr:primaryType="nt:unstructured">
<cq:styles jcr:primaryType="nt:unstructured">
<title <-- EXISTING STYLE
cq:styleClasses="cmp-hero-banner--title-only"
cq:styleId="hero-banner--title-only"
cq:styleLabel="Page Title"
jcr:primaryType="nt:unstructured"/>
<half-height <-- ADDED STYLE
cq:styleClasses="half-height"
cq:styleId="half-height"
cq:styleLabel="Half Height"
jcr:primaryType="nt:unstructured"/>
<full-height <-- EXISTING STYLE
cq:styleClasses="full-height"
cq:styleId="full-height"
cq:styleLabel="Full Height"
jcr:primaryType="nt:unstructured"/>
</cq:styles>
</display-variation>

My issue is that these changes I make are not added to the server. The htl, css, and js files are updated, but not the component policies. What could I be doing wrong?

1 Accepted Solution

Avatar

Correct answer by
Level 6

Hi @rkody Please try deleting (or) renaming the project folder (conf/project) from CRX DE and then re-deploy the code.
If you are deleting it, make sure you make a backup package.
If you are renaming it, just give it a random name like in my case I append _v1 or _v2 or something like that.
On re-deploying the code, you will see a new folder. You will see the latest policies set in code there.

View solution in original post

6 Replies

Avatar

Community Advisor

When you say that changes are not there, did you check in crxde or just that the styles are not coming when authors are using the style system ?
And these are kept as part of ui.content module ?
One basic thing which I see is that don't keep entire /conf in your filter. It will be better if you keep it limited to your project.

<filter root="/conf/myproject" mode="merge"/>

 

Avatar

Correct answer by
Level 6

Hi @rkody Please try deleting (or) renaming the project folder (conf/project) from CRX DE and then re-deploy the code.
If you are deleting it, make sure you make a backup package.
If you are renaming it, just give it a random name like in my case I append _v1 or _v2 or something like that.
On re-deploying the code, you will see a new folder. You will see the latest policies set in code there.

Avatar

Level 4

This worked for me thank you for your reply!

 

However, to be frank this seems like a bug. Luckily, I don't need to update the policies all the time, but it does not make sense that I would need to rename or delete the entire /myproject/ folder for changes in code to show up.

Avatar

Level 6

Haha, I think it's the normal behavior. May be there is some configuration which is responsible for this something like AEM's internal caching and for default it is set to /apps and /content but not for /conf.
I will definitely share the solution here if I got the reason for this. It was happening in my project also.

Avatar

Level 4

Hi @rkody,

 

Can you try to to replicate in your local, and if you are still not able to see the policy changes.

Try adding one more filter by making the mode to replace but by specifying the exact path, something like below.

<filter root="/conf/project/settings/wcm/policies" mode="replace"/>

Make sure to add replace filters first and then the merge one's.

I have faced something similar recently and this resolved.

Avatar

Administrator

@rkody Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!  



Kautuk Sahni