Table of Contents

Generates a tree of categories and pages of a given root category

Renders contents tree for a given category.

Git repository

#1. Installation

  1. Download the ZIP and unpack it.
  2. Copy 'toc' to your plugins folder.
  3. Install via Administration / Extensions.

#2. Demo

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.

#3. Usage

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.


1. elfrenazo  28.06.2012 13:54

too complicated for me

2. ezisLV  15.05.2016 18:08

looks like something i'm looking for 

3. Hantr  20.10.2016 20:24

Подскажите этот плагин по умолчанию работает по ссылке https://www.наименование.ru/docs/ ? Поставил на последнюю версию он у меня почему то не работает..

4. Macik  31.10.2016 22:23

Он работает там где вызван из шаблона,  пример: `{PHP|toc('docs', 'toc.main')}`

А `docs` это просто альяс (код) категории. А чтобы можно было заходить в категории по соотв. ссылки — надо включить ЧПУ, посредством плагина urleditor и установить пресет «удобный».

Додавання комментарів доступно лише зареєстрованим користувачам