MODX: TableOfContentsX

A new MODX extra for creating a Table of Contents based on the resources content.

TableOfContentsX

This extra takes your MODX content and creates an ordered list Table of Contents based on the h1, h2, h3, h4, h5 and h6 tags. This can be used so that long articles and pages can be broken down and makes it easier for the user to click a section they'd like to jump to.

Download TableOfContentsX


Usage

This is the main/only snippet included in this package and takes a template variable/chunk/placeholder and generates the Table Of Contents. The snippet has one parameter and that is to select what it should output:-

  • toc - This will output an ordered list with links to your page header tags
  • content - This will output your page content with your header tags with anchors

A typical way of using this would be to do the following: -

[[*content:TableOfContentsX=`toc`]]
[[*content:TableOfContentsX=`content`]]

Support & Credits

If you have any problems or have ideas/suggestions, please let me know on the TableOfContentsX Github page.

Based on code by Joost de Valk, http://www.westhost.com/contest/php/function/create-table-of-contents/124


Comments 0

There are no comments on this yet.

Got something to say?

Join the discussion! You know how these things work; enter your details and comments below and be heard.

  1. Allowed tags: <b><i><br>