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

how to restrict allowed components in policy properties aem for editable template

Avatar

Level 1

one of our requirement is see if we can make changes to the layout policy properties, where we can restrict the allowed components that gets displayed for selection.

 

i.e. we want only our project component group to be displayed there instead of the whole groups (ex: General, ACS Commons .. e.t.c) that are available for selection as shown below.

 

 

 

Screen Shot 2020-08-04 at 12.52.16 PM.png

 

 

 @smacdonald2008 @Jörg_Hoh @kautuk_sahni @arunpatidar @BrianKasingli @Theo_Pendle 

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

/libs/cq/gui/components/authoring/allowedcomponents/AllowedComponents.java is responsible to fetch all the components and shows in the allowed component part.

You can overlay /libs/cq/gui/components/authoring/allowedcomponents/allowedcomponents.html and add data-sly-test for ACS Common component groups

 

 

<coral-search placeholder="${'Search' @ i18n}" class="js-cq-AllowedComponents-filter cq-AllowedComponents-filter"></coral-search>
<coral-accordion variant="quiet" class="cq-AllowedComponents js-cq-AllowedComponents">
    <!--/* render component groups */-->
    <sly data-sly-use.api="libs.cq.gui.components.authoring.allowedcomponents.AllowedComponents"
        data-sly-repeat.group="${api.groups}">
        <sly data-sly-test=${group.title!='ACS Commons'} data-sly-use.template="componentgroup.html"
            data-sly-call="${template.componentGroup @ group=group}"/>
    </sly>
</coral-accordion>

 

 

 



Arun Patidar

View solution in original post

8 Replies

Avatar

Correct answer by
Community Advisor

Hi,

/libs/cq/gui/components/authoring/allowedcomponents/AllowedComponents.java is responsible to fetch all the components and shows in the allowed component part.

You can overlay /libs/cq/gui/components/authoring/allowedcomponents/allowedcomponents.html and add data-sly-test for ACS Common component groups

 

 

<coral-search placeholder="${'Search' @ i18n}" class="js-cq-AllowedComponents-filter cq-AllowedComponents-filter"></coral-search>
<coral-accordion variant="quiet" class="cq-AllowedComponents js-cq-AllowedComponents">
    <!--/* render component groups */-->
    <sly data-sly-use.api="libs.cq.gui.components.authoring.allowedcomponents.AllowedComponents"
        data-sly-repeat.group="${api.groups}">
        <sly data-sly-test=${group.title!='ACS Commons'} data-sly-use.template="componentgroup.html"
            data-sly-call="${template.componentGroup @ group=group}"/>
    </sly>
</coral-accordion>

 

 

 



Arun Patidar

Avatar

Level 1

Hi Arun,

Thanks for the reply, But here I dont want any of those groups.

I only need my project group. thats it.

 

Is there a way to restrict to show only my project group for component selection?

 

@arunpatidar 

 

Avatar

Community Advisor
Yes, either you create your own allow component resource type like /libs/cq/gui/components/authoring/allowedcomponents or update above html to add condition to skip other groups except yours. I would suggest create your own type.


Arun Patidar

Avatar

Community Advisor

@AEM_65, also, you can also include some logic in /libs/cq/gui/components/authoring/allowedcomponents/AllowedComponents.java, during the overlay, to ensure that only specific group members are affected by the restricted view. Or your AEM environment will no longer be able to view other components going forward, unless if this is fine.

Avatar

Level 1

Hi Arun,

 

I tried to make the above mentioned changes. But when ever I have written the data-sly-test condition in the allowedcomponents.html in libs, the layout policy configuration itself it not opening.

 

Looks like this solution isnt working.

 

Can you please check this once.

 

Screen Shot 2020-08-05 at 10.03.33 AM.png

 

Thanks.

 

 

CC @arunpatidar  @BrianKasingli  @kautuk_sahni 

Avatar

Level 1
Hi Arun, I tried to make the above mentioned changes. But when ever I have written the data-sly-test condition the layout policy configuration itself it not opening, i.e. no action is being performed after clicking this action button

Avatar

Community Advisor

Hi,

It could be because of syntax error in the answer which I shared with you. I forgot to enclosed data-sly-test condition

<div data-sly-test.isEditMode="${wcmmode.edit}">${isEditMode}</div>

 

  <sly data-sly-test="${group.title!='ACS Commons'}" data-sly-use.template="componentgroup.html"
            data-sly-call="${template.componentGroup @ group=group}"/>

 

 



Arun Patidar

Avatar

Community Advisor

is this resolved? Let me know if you still looking for solution.

I created a custom allowed type with Generic approach. I will share the complete solution.

 

Arun_Patidar_0-1597076738167.png

 



Arun Patidar