Add Component to two componentGroup | Community
Skip to main content
Level 2
Oct 22, 2020 7:01 PM UTC
Solved

Add Component to two componentGroup

I would like to add myComponent to two or more componentGroup,

 

How can I do that?

 

<?xml version="1.0" encoding="UTF-8"?>
    jcr:primaryType="cq:Component"
    jcr:title="MyComponent"
    sling:resourceSuperType="custom/components/content/mycomponent/v1/mycomponent"
    componentGroup="first group"/>


I tried:
componentGroup="first group, second group" 
componentGroup="[first group, second group]" but it does not work
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Anudeep_Garnepudi
Anudeep_GarnepudiAccepted solution
New Participant
Oct 24, 2020 5:52 AM UTC

Hi @maynorsong 

A component can be part of at most one Component Group (Hidden or any Group). If you want to have same component two groups, it is not possible directly but here is my suggestion.

  1. Duplicate the existing component
  2. Delete all the resources under copied component
  3. Make original component as parent(sling:resourceSuperType)
  4. Change the Component Group

I suggest to do this only if it is highly required, because this way it gives an impression like same component is under two groups but they are not actually one component. We are trying to achieve 100% inheritance here. 

 

Note: sling:resourceType for these components will not be same once authored on a page

 

AG

3 replies

arunpatidar
New Participant
Oct 25, 2020 7:09 PM UTC

Why don't create this component with common group

componentGroup="common-a group" 

 

or another option to proxy MyComponent as MyComponent2

Translate
Arun Patidar
Anudeep_Garnepudi
Anudeep_GarnepudiAccepted solution
New Participant
Oct 24, 2020 5:52 AM UTC

Hi @maynorsong 

A component can be part of at most one Component Group (Hidden or any Group). If you want to have same component two groups, it is not possible directly but here is my suggestion.

  1. Duplicate the existing component
  2. Delete all the resources under copied component
  3. Make original component as parent(sling:resourceSuperType)
  4. Change the Component Group

I suggest to do this only if it is highly required, because this way it gives an impression like same component is under two groups but they are not actually one component. We are trying to achieve 100% inheritance here. 

 

Note: sling:resourceType for these components will not be same once authored on a page

 

AG

Translate
Shashi_Mulugu
New Participant
Oct 23, 2020 1:50 AM UTC

@maynorsong you cannot do it in AEM.

 

May I know why do you want to do it so that we may suggest you a better way.

Translate