Renders contents tree for a given category.
- Download.
- Copy 'toc' to your plugins folder.
- Install via Administration / Extensions.
To see the plugin in action visit Cotonti Documentation. Both the documentation index page and sidebar on the right on regular pages like this are generated with this plugin.
The plugin provides a callback/widget that can be used in page.list.tpl and page.tpl files (including category-specific files).
The following will print entire table of contents for category with code 'docs':
{PHP|toc('docs')}
By default 'toc.tpl' is used to generate a TOC, but you can use custom TPL files for different widgets. The following will generate a TOC using toc.main.tpl:
{PHP|toc('docs', 'toc.main')}
In subcategories and on regular pages you wouldn't like to include the full tree. You can tell the widget to show pages for current category only:
{PHP|toc('docs', 'toc', 1)}
This will leave all the non-current categories collapsed.
Use CSS to style the TOC. Here is an example:
ul.toc {
list-style: none;
margin: 10px 10px 10px 20px;
display: block;
clear: both;
}
ul.toc a.current {
background-color: lightYellow;
}
ul.toc-main {
list-style: none;
margin: 10px 10px 10px 40px;
display: block;
clear: both;
}
ul.toc-main a.level-1.cat {
font-size: 180%;
}
ul.toc-main a.level-2.cat {
font-size: 150%;
}
ul.toc-main a.level-3.cat {
font-size: 120%;
}
For more information see 'toc.php' source and PHPDoc blocks in it.