Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

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

AEM_65
Level 1
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 @Arun_Patidar @BrianKasingli @Theo_Pendle 

AEM aem6.5 Editable templates Layout policy
1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
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>

 

 

 

View solution in original post

8 Replies
Arun_Patidar
Correct answer by
Community Advisor
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>

 

 

 

View solution in original post

AEM_65
Level 1
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?

 

@Arun_Patidar 

 

Arun_Patidar
Community Advisor
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.
BrianKasingli
Community Advisor
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.

AEM_65
Level 1
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 @Arun_Patidar  @BrianKasingli  @kautuk_sahni 

AEM_65
Level 1
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
Arun_Patidar
Community Advisor
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
Community Advisor
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