Table of contents Delegation | Adobe Higher Education
Skip to main content
Level 2
January 7, 2025
Beantwortet

Table of contents Delegation

  • January 7, 2025
  • 2 Antworten
  • 842 Ansichten

Hi, Table of contents is a core component and it seems to suit our project requirements well. I have created a copy of it with supertype pointing to the ootb component. But, I do not require the page name that's displayed as part of the TOC list. I tried to check  the implementation and seems like a filter is being used which I am unable to delegate. Moreover, the rendering of the component is not in html and I am trying to see how the rendering is done. Any information on the end-end flow of the component functionality will be useful to achieve my requirements. Thanks !

Beste Antwort von arunpatidar

Hi @sahana_s 

Did you triedignoreClasses property from policy to ignore items in the TOC?

https://experienceleague.adobe.com/en/docs/experience-manager-core-components/using/wcm-components/tableofcontents#properties-tab 

2 Antworten

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 7, 2025

Hi,

 

AFAIK, the table of contents doesn't display any "page" information (if we're talking about an AEM page). Instead, it relies on the HTML rendered on the page. It scans the content and based on what it finds, it generates the table of contents. You can check that code here how this is being rendered: https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/TableOfContentsFilter.java#L302 

 

So, if you need to change the text in the ToC, you’ll need to update the title of the corresponding element. For example:

 

 

I hope this helps.

 

Esteban Bustamante
Level 2
January 8, 2025

Thank you for the reply @estebanbustamante . I understand the functionality works by parsing the h1 - h5 tags, but what about the Title/Pagename "Esteban Demo site". I tried to exclude the class name that page title uses but it didn't work. I want to omit the title it displays.

Level 2
January 9, 2025

Sorry, I misunderstood your question. In that case, what Arun pointed out will work. You need to add a "unique distinctive class" to your title component (the <h> element), and then include this class in the Table of Content component policy.

 

Something like this:

Then in the component policy: 

Result, the first title has the "ignore-toc" class and won't appear in the ToC component:

 

You could also provide an option for authors to toggle the "ignore-toc" class, allowing them to choose whether to display or exclude the title from the Table of Contents.

 

Hope this helps

 


Thank you @arunpatidar and @estebanbustamante , as per suggestions I added a unique class and then added it to the list of classes to be ignored in TOC style policy. It worked. 

kautuk_sahni
Community Manager
Community Manager
January 27, 2025

@sahana_s Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Kautuk Sahni