Disable sub components from admin | Community
Skip to main content
Level 2
March 22, 2021
Solved

Disable sub components from admin

  • March 22, 2021
  • 3 replies
  • 1581 views

Hello everyone, 

 

I have a master component which contains a list of subcomponents. All of the them are custom components. I now working on a task to disable some of the subcomponents. I don't want to just delete them but rather to hide them from the admin. I know I can do so from the content policy configuration through the design dialog. But I want to do this through the code. I was wondering if anyone can point me to the right direction, such as the specific the file path and what I need to modify. I tried to search online but couldn't find anything. Thanks in advance for your help. 

 

Lucy

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 BrianKasingli

@lucy.wang, there are three ways that I have done this in the past.

1. Just making sure that your componentGroup is set to .hidden

 

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Component" jcr:title="Image Carousel" jcr:description="Image Carousel Component for Content Creation" componentGroup=".hidden"/>

 


2. Just making sure your sub-components have a unique componentGroup name, and then using the "cq:EditListenersConfig" configuration, to update the components list.

 

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" cq:actions="[edit]" cq:dialogMode="floating" cq:disableTargeting="{Boolean}true" jcr:primaryType="cq:EditConfig"> <cq:listeners jcr:primaryType="cq:EditListenersConfig" updatecomponentlist="function(a,b) { b.length = 0; b.push('/apps/my-site/components/content/carousels/imagecarousel'); b.push('/apps/my-site/components/content/carousels/tabbedcarousel'); }"/> </jcr:root>

 

3. If your parent component is a parsys, then you can add policies to that parsys within editable templates!

Options 1 or 2, a code deployment must be made if you want to enable or disable sub-components of a component. 

3 replies

Pawan-Gupta
Level 8
March 22, 2021

Hello,

 

the best way to avoid admin conflict is to move under new group like .hidden or hidden which gives perfect sense to admin and supported by AEM both classic and touch

 

set property at component node level as

 

componentGroup     String          .hidden or hidden

 

Thanks!!

Rohit_Utreja
Community Advisor
Community Advisor
March 22, 2021

Hi @lucy.wang,

 

If you don't want to show this specific set of components to admin, I assume that these sub-components will not be exposed to any other user as well.

 

In this case, you can add componentGroup as ".hidden" in the component properties.'

 

https://experienceleague.adobe.com/docs/experience-manager-64/developing/components/components-basics.html?lang=en#component-hierarchy-and-inheritance

 

kautuk_sahni
Community Manager
Community Manager
March 23, 2021
@rohit_utreja, thank you for proactively assisting the community. This is great community work. Please keep it up.
Kautuk Sahni
BrianKasingli
Community Advisor and Adobe Champion
BrianKasingliCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
March 22, 2021

@lucy.wang, there are three ways that I have done this in the past.

1. Just making sure that your componentGroup is set to .hidden

 

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Component" jcr:title="Image Carousel" jcr:description="Image Carousel Component for Content Creation" componentGroup=".hidden"/>

 


2. Just making sure your sub-components have a unique componentGroup name, and then using the "cq:EditListenersConfig" configuration, to update the components list.

 

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" cq:actions="[edit]" cq:dialogMode="floating" cq:disableTargeting="{Boolean}true" jcr:primaryType="cq:EditConfig"> <cq:listeners jcr:primaryType="cq:EditListenersConfig" updatecomponentlist="function(a,b) { b.length = 0; b.push('/apps/my-site/components/content/carousels/imagecarousel'); b.push('/apps/my-site/components/content/carousels/tabbedcarousel'); }"/> </jcr:root>

 

3. If your parent component is a parsys, then you can add policies to that parsys within editable templates!

Options 1 or 2, a code deployment must be made if you want to enable or disable sub-components of a component. 

lucy.wangAuthor
Level 2
March 23, 2021
Thank you @briankasingli