NAME

App::ZofCMS::Plugin::TOC - Table of Contents building plugin for ZofCMS

SYNOPSIS

In your ZofCMS template, or in your main config file (under template_defaults or dir_defaults):

page_toc    => [
    qw/
        #overview
        #beginning
        #something_else
        #conclusion
    /,
],
plugins     => [ qw/TOC/ ],

# OR

page_toc    => [
    [ qw/#overview Overview class_overview/ ],
    [ qw/#beginning Beginning/ ],
    qw/
        #something_else
        #conclusion
    /,
],
plugins     => [ qw/TOC/ ],

In your HTML::Template template:

<tmpl_var name="page_toc">

DESCRIPTION

This plugin provides means to generate "table of contents" lists. For example, the second example in the SYNOPSYS would replace <tmpl_var name="page_toc"> with this:

<ul class="page_toc">
    <li class="class_overview"><a href="#overview">Overview</a></li>
    <li><a href="#beginning">Beginning</a></li>
    <li><a href="#something_else">Something Else</a></li>
    <li><a href="#conclusion">Conclusion</a></li>
</ul>

HOW TO USE

Aside from sticking TOC in your arrayref of plugins in your ZofCMS template (plugins => [ qw/TOC/ ]) and placing <tmpl_var name="page_toc"> in your HTML::Template template you also need to create a page_toc first level key in ZofCMS template. That key's value is an arrayref each element of which can be either an arrayref or a scalar. If the element is a scalar it is the same as it being an arrayref with one element. The element which is an arrayref can contain either one, two or three elements itself. Which represent the following:

arrayref which contains only one element

page_toc => [
    '#foo',
    '#bar-baz',
],

# OR

page_toc => [
    [ '#foo' ],
    [ '#bar-baz' ],
],

The first (and only) element will be used in href="" attribute of the generated link. The text of the link will be determined automatically, in particular the '#' will be removed, first letter will be capitalized and any dashes '-' or underscores '_' will be replaced by a space with the letter following them capitalized. The example above will place the following code in <tmpl_var name="page_toc">:

<ul class="page_toc">
    <li><a href="#foo">Foo</a></li>
    <li><a href="#bar-baz">Bar Baz</a></li>
</ul>

arrayref which contains two elements

page_toc => [
    [ '#foo', 'Foos Lots of Foos!' ],
    [ '#bar-baz', 'Bar-baz' ],
],

The first element will be used in href="" attribute of the generated link. The second element will be used as text for the link. The example above will generate the following code:

<ul class="page_toc">
    <li><a href="#foo">Foos Lots of Foos!</a></li>
    <li><a href="#bar-baz">Bar-baz</a></li>
</ul>

arrayref which contains three elements

page_toc => [
    [ '#foo', 'Foos Lots of Foos!', 'foos' ],
    [ '#bar-baz', 'Bar-baz', 'bars' ],
],

The first element will be used in href="" attribute of the generated link. The second element will be used as text for the link. The third elemenet will be used to create a class="" attribute on the <li> element for the corresponding entry. The example above will generate the following code:

<ul class="page_toc">
    <li class="foos"><a href="#foo">Foos Lots of Foos!</a></li>
    <li class="bars"><a href="#bar-baz">Bar-baz</a></li>
</ul>

Note: the class of the <ul> element is always page_toc

AUTHOR

Zoffix Znet, <zoffix at cpan.org> (http://zoffix.com, http://haslayout.net)

BUGS

Please report any bugs or feature requests to bug-app-zofcms-plugin-toc at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-ZofCMS-Plugin-TOC. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc App::ZofCMS::Plugin::TOC

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2008 Zoffix Znet, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.