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?
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
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.
@EduardoBo3 have you tried using granite include?
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.
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?
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.
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.
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.
Views
Likes
Replies
Views
Likes
Replies