Is there a way to reuse AEM policy styleGroups? | Community
Skip to main content
EduardoBo3
New Participant
July 26, 2024
Solved

Is there a way to reuse AEM policy styleGroups?

  • July 26, 2024
  • 3 replies
  • 1831 views

I'm starting working with AEM style System and I'm facing a challenge regarding reusability. I have a ColumnControl which has more than one column, and I need to offer authors several styles for the columns – which I've already implemented through a policy linked to the columns.

 

<policy_col jcr:primaryType="nt:unstructured" sling:resourceType="wcm/core/components/policy/policy" components="[...]"> <cq:styleGroups jcr:primaryType="nt:unstructured"> <style1 jcr:primaryType="nt:unstructured" cq:styleGroupLabel="1"> <cq:styles jcr:primaryType="nt:unstructured"> ... </cq:styles> </style1> <style2 jcr:primaryType="nt:unstructured" cq:styleGroupLabel="2"> <cq:styles jcr:primaryType="nt:unstructured"> ... </cq:styles> </style2> ...

 

But each column needs to allow different components, which means each column needs to have a different policy. But I wouldn't like to have to repeat all the styles for both policies:

 

<policy_col1 jcr:primaryType="nt:unstructured" sling:resourceType="wcm/core/components/policy/policy" components="[...]"> <cq:styleGroups jcr:primaryType="nt:unstructured"> <style1 jcr:primaryType="nt:unstructured" cq:styleGroupLabel="1"> <cq:styles jcr:primaryType="nt:unstructured"> ... </cq:styles> </style1> <style2 jcr:primaryType="nt:unstructured" cq:styleGroupLabel="2"> <cq:styles jcr:primaryType="nt:unstructured"> ... </cq:styles> </style2> </cq:styleGroups> </policy_col1> <policy_col2 jcr:primaryType="nt:unstructured" sling:resourceType="wcm/core/components/policy/policy" components="[... different list]"> <cq:styleGroups jcr:primaryType="nt:unstructured"> <style1 jcr:primaryType="nt:unstructured" cq:styleGroupLabel="1"> <cq:styles jcr:primaryType="nt:unstructured"> ... </cq:styles> </style1> <style2 jcr:primaryType="nt:unstructured" cq:styleGroupLabel="2"> <cq:styles jcr:primaryType="nt:unstructured"> ... </cq:styles> </style2> </cq:styleGroups> </policy_col2>

 

Is there any way I can link one policy to an already defined anywhere cq:styleGroups?

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 aanchal-sikka

@eduardobo3 

 

We can share a policy for a "component across multiple templates" or "multiple occurrences of same component on a template".

But, we cannot share parts of it like just the Style System. It can be shared only as a whole.

 

While creating a new policy we can duplicate an existing one and then tweek it for allowed components.

3 replies

aanchal-sikka
aanchal-sikkaAccepted solution
New Participant
July 28, 2024

@eduardobo3 

 

We can share a policy for a "component across multiple templates" or "multiple occurrences of same component on a template".

But, we cannot share parts of it like just the Style System. It can be shared only as a whole.

 

While creating a new policy we can duplicate an existing one and then tweek it for allowed components.

Aanchal Sikka
EduardoBo3
New Participant
July 29, 2024

Thank you @aanchal-sikka , I did all the tests to confirm this and unfortunately, as you said, it's not possible to share .xml parts of it, such as just the Style System.

abhishekanand_
New Participant
July 27, 2024

Hi @eduardobo3 

 

i have written a blog on this a year ago, attaching the blog link for reference:

https://www.tothenew.com/blog/how-to-configure-components-efficiently-in-aem-with-parameterized-namespace-include/

Abhishek Anand
aanchal-sikka
New Participant
July 28, 2024

@abhishekanand_ 

 

Thanks for sharing the Article. 

"acs-commons/granite/ui/components/include” I have used it for Component Dialogs. Does it also work with component policies?

Aanchal Sikka
EduardoBo3
New Participant
July 29, 2024

Thank you for you help, but it appears that both "granite/ui/components/coral/foundation/include" and "acs-commons/granite/ui/components/include" only work to dialogs features. I need a solution to share component policies like you said @aanchal-sikka.

Shashi_Mulugu
New Participant
July 27, 2024
EduardoBo3
New Participant
July 29, 2024

Thank you for you help, but it appears that "granite/ui/components/coral/foundation/include" only works to dialogs features. I need a solution to share component policies.