Updating component and template policies in code | Community
Skip to main content
rkody
June 24, 2024
Solved

Updating component and template policies in code

  • June 24, 2024
  • 4 replies
  • 2256 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kapil_rajoria

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.

4 replies

h_kataria
Community Advisor
Community Advisor
June 25, 2024

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"/>

 

kapil_rajoria
Community Advisor
kapil_rajoriaCommunity AdvisorAccepted solution
Community Advisor
June 25, 2024

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.

rkody
rkodyAuthor
June 25, 2024

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.

kapil_rajoria
Community Advisor
Community Advisor
July 27, 2024

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.

June 25, 2024

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.

kautuk_sahni
Community Manager
Community Manager
June 25, 2024

@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