Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Is there a way to reuse AEM policy styleGroups?

Avatar

Level 2

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?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@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

View solution in original post

7 Replies

Avatar

Level 2

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.

Avatar

Community Advisor

@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

Avatar

Level 2

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.

Avatar

Correct answer by
Community Advisor

@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

Avatar

Level 2

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.