Expand my Community achievements bar.

SOLVED

Disable sub components from admin

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@lwang, 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. 

View solution in original post

5 Replies

Avatar

Level 9

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!!

Avatar

Community Advisor

Hi @lwang,

 

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-basic...

 

Avatar

Administrator
@Rohit_Utreja, thank you for proactively assisting the community. This is great community work. Please keep it up.


Kautuk Sahni

Avatar

Correct answer by
Community Advisor

@lwang, 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.