Page TOC Generator 0.9.2

Page TOC Generator 0.9.2

Released Dec 08, 2007 by
Automatically generate a page-specific table of contents from the page's headings. Configurable, stylable. It creates a list (<ul> or <ol>) of links to the headings within that page. It automatically generates the anchors, so you just have to create the headings. It's a site-wide plugin, so it's easy to put a "Page Contents" feature on any page on your site. Download 14kb (1089 downloads)
Downloads: 3,629
License: GPL - GNU Public
Discuss Extra
Requires Evolution 1.0.x or greater
Supports mysql
Automatically generate a page-specific table of contents from the page's headings. Configurable, stylable.

Installation Instructions

### INSTALLATION: ###

1. Create a new Plugin called "Page TOC Generator".
2. Paste in the PHP code of this file.
3. Go to the "System Events" tab
4. Check the box in front of "OnWebPagePrerender"

### HOW TO USE: ###

1. Create a page in MODx as usual
2. Add appropriate headings on that page to divide up the sections of the page into a sort of outline
3. In the HTML code of that page, add the configuration parameters (see below -- these look like normal HTML comments, but are parsed by the plugin).
4. Put the <!--#toc_plugin#_START_TOC_INDEXING--> tag at the spot where you want to begin indexing the page's headings.
5. Put the <!--#toc_plugin#_END_TOC_INDEXING--> tag where you want the indexing to stop.
6. Put the <!--#toc_plugin#_TOC_OUTPUT--> tag where you want the table of contents to show up.

### CONFIGURATION PARAMETERS: ###

<!--#toc_plugin#_START_CONFIGURATION--> (optional)
<!--#toc_plugin#_list_type=ul--> sets the list type (ul/ol).
<!--#toc_plugin#_start_level=1--> Sets the starting heading level (h1-h6).
<!--#toc_plugin#_end_level=2--> Sets the ending heading level (h1-h6).
<!--#toc_plugin#_header=Page Contents--> Sets the text of the heading for table of contents.
<!--#toc_plugin#_header_tag=h2--> Sets the tag which encloses the heading (could be a heading, <p>, <div>, etc.
<!--#toc_plugin#_parent_tag=div--> Sets the parent tag which encloses table of contents. you can leave it blank.
<!--#toc_plugin#_parent_tag_id=toc--> Sets the CSS id which is applied to the parent tag.
<!--#toc_plugin#_END_CONFIGURATION--> (optional)


### SAMPLE USAGE: ###

<!--#toc_plugin#_START_CONFIGURATION-->
<!--#toc_plugin#_list_type=ul-->
<!--#toc_plugin#_start_level=2-->
<!--#toc_plugin#_end_level=3-->
<!--#toc_plugin#_header=Page Contents-->
<!--#toc_plugin#_header_tag=h2-->
<!--#toc_plugin#_parent_tag=div-->
<!--#toc_plugin#_parent_tag_id=toc-->
<!--#toc_plugin#_END_CONFIGURATION-->

<!--#toc_plugin#_TOC_OUTPUT-->

<!--#toc_plugin#_START_TOC_INDEXING-->
<h2>Here is a heading</h2>
<p>Here is some text</p>
<h2>Here is another heading</h2>
<h3>Here is a subheading</h3>
<h3>Here is another subheading</h3>
<!--#toc_plugin#_END_TOC_INDEXING-->


### EXPECTED OUTPUT: ###

<div id="toc">
<h2>Page Contents</h2>
<ul>
<li><a href="#Here is a heading_1">Here is a heading</a></li>
<li><a href="#Here_is_another_heading_2">Here is another heading</a>
<ul>
<li><a href="#Here_is_a_subheading_3">Here is a subheading</a></li>
<li><a href="#Here_is_another_subheading_4">Here is another subheading</a></li>
</ul>
</li>
</ul>
</div>

<h2><a name="Here is a heading_1" id="Here is a heading_1"></a>Here is a heading</h2>
<p>Here is some text</p>
<h2><a name="Here_is_another_heading_2" id="Here_is_another_heading_2"></a>Here is another heading</h2>
<h3><a name="Here_is_a_subheading_3" id="Here_is_a_subheading_3"></a>Here is a subheading</h3>
<h3><a name="Here_is_another_subheading_4" id="Here_is_another_subheading_4"></a>Here is another subheading</h3>

Updates

* Added default values, so you don't have to specify them on each page
* Made the markers customizable, so you can use your own
* Changed regular expression replace to string replace for final step
Version Released Author Downloads
4 Versions 2 Contributors 3,632 Downloads
0.90.0 Dec, 03 2007 Samit Vartak, Paul Bohman 751
0.76.0 Feb, 26 2007 Samit Vartak 883
0.7.0 Jan, 20 2007 Samit Vartak 909