How do you configure an extended core component? | Community
Skip to main content
Art_Bird
Level 2
April 12, 2024
Solved

How do you configure an extended core component?

  • April 12, 2024
  • 4 replies
  • 1249 views

I'm reading the docs on the core Table of Contents Component. The GitHub readme says "./includeClasses - defines an array of strings representing the configured class names to include in the TOC." Where do you add the ./includeClasses property and does it need a true value set for it to work?

I've read the docs and clearly missing something.

Link to GitHub readme for Component Policy Configuration Properties - https://github.com/adobe/aem-core-wcm-components/blob/main/content/src/content/jcr_root/apps/core/wcm/components/tableofcontents/v1/tableofcontents/README.md#component-policy-configuration-properties

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 partyush

Hi @art_bird 

When extending an AEM core component, you typically achieve configuration through a process called "overlays." Here's how to configure the "./includeClasses" property for your custom Table of Contents component:

  1. Create a New Component:

    • In CRXDE Lite, navigate to your project's /apps directory.
    • Create a folder structure mirroring the core component's path (e.g., /apps/yourproject/components/content/toc if the core component is at /libs/foundation/components/toc).
  2. Define the Overlay:

    • Inside your new component folder (e.g., /apps/yourproject/components/content/toc), create a file named .content.xml.
    • Within this file, define a node of type cq:component that inherits from the core component using the sling:resourceSuperType property. Here's an example:
    XML
    <cq:component xmlns:sling="http://sling.apache.org/sling/sling-content/1.0"
                 jcr:primaryType="cq:Component"
                 sling:resourceSuperType="/libs/foundation/components/toc">
    
      </cq:component>
  3. Set the "./includeClasses" Property:

    • Inside the cq:component node you created, add a child node of type sling:property. Set the following attributes for this node:
      • name: Set this to ./includeClasses.
      • value: Set this to an array of strings representing the class names you want to include (e.g., value="['MyCustomClass1', 'MyCustomClass2']").

    Here's the complete example with the "./includeClasses" property:

    XML
    <cq:component xmlns:sling="http://sling.apache.org/sling/sling-content/1.0"
                 jcr:primaryType="cq:Component"
                 sling:resourceSuperType="/libs/foundation/components/toc">
    
      <sling:property name="./includeClasses" value="['MyCustomClass1', 'MyCustomClass2']" />
    
      </cq:component>




  • This approach leverages AEM's content repository (CRX) to configure the extended component.
  • You don't need to set the property to "true". The presence of the property with the desired value (the array of class names) is sufficient.
  • Remember to activate your changes after saving the .content.xml file.

Thanks 

4 replies

arunpatidar
Community Advisor
Community Advisor
April 12, 2024
partyush
Community Advisor
partyushCommunity AdvisorAccepted solution
Community Advisor
April 13, 2024

Hi @art_bird 

When extending an AEM core component, you typically achieve configuration through a process called "overlays." Here's how to configure the "./includeClasses" property for your custom Table of Contents component:

  1. Create a New Component:

    • In CRXDE Lite, navigate to your project's /apps directory.
    • Create a folder structure mirroring the core component's path (e.g., /apps/yourproject/components/content/toc if the core component is at /libs/foundation/components/toc).
  2. Define the Overlay:

    • Inside your new component folder (e.g., /apps/yourproject/components/content/toc), create a file named .content.xml.
    • Within this file, define a node of type cq:component that inherits from the core component using the sling:resourceSuperType property. Here's an example:
    XML
    <cq:component xmlns:sling="http://sling.apache.org/sling/sling-content/1.0"
                 jcr:primaryType="cq:Component"
                 sling:resourceSuperType="/libs/foundation/components/toc">
    
      </cq:component>
  3. Set the "./includeClasses" Property:

    • Inside the cq:component node you created, add a child node of type sling:property. Set the following attributes for this node:
      • name: Set this to ./includeClasses.
      • value: Set this to an array of strings representing the class names you want to include (e.g., value="['MyCustomClass1', 'MyCustomClass2']").

    Here's the complete example with the "./includeClasses" property:

    XML
    <cq:component xmlns:sling="http://sling.apache.org/sling/sling-content/1.0"
                 jcr:primaryType="cq:Component"
                 sling:resourceSuperType="/libs/foundation/components/toc">
    
      <sling:property name="./includeClasses" value="['MyCustomClass1', 'MyCustomClass2']" />
    
      </cq:component>




  • This approach leverages AEM's content repository (CRX) to configure the extended component.
  • You don't need to set the property to "true". The presence of the property with the desired value (the array of class names) is sufficient.
  • Remember to activate your changes after saving the .content.xml file.

Thanks 

RikVanB
Level 2
April 15, 2024

Hi @art_bird 

You can just extend the Table of Contents Component like they did with the Byline Component in the official course of Adobe: https://experienceleague.adobe.com/en/docs/experience-manager-learn/getting-started-wknd-tutorial-develop/project-archetype/custom-component

 

Just make sure that the sling:resourceSuperType is pointing to the right Core Component, in this case core/wcm/components/tableofcontents/v1/tableofcontents.

 

If you do this all the configuration options like includeClasses will be available on your extended core component.

 

Hope this helps!

 

Greetings

Rik

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 15, 2024

@art_bird Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community

Esteban Bustamante
EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 18, 2024
Esteban Bustamante