Section list

On this page:


<txp:section_list />

The section_list tag is a single or container tag which is used to produce a list of linked sections. When used as a container tag, it is used as an opening and closing pair, like this:

    ...contained statements...


Tag will accept the following attributes (case-sensitive):

active_class="class name" (only works in the single tag without the form attribute)
HTML class to apply to the ‘active’ or current link in a list.
Default: unset
Text used as a title for the ‘default’ section when include_default is set to 1.
Default: site name.
exclude="section name(s)"
Comma-separated list of section names to exclude from the list. sections takes precedence over exclude.
Default: unset (none).
form="form name"
Use specified form template to process each included section.
Default: unset.
The HTML id attribute applied to the wraptag, if set.
Whether to include ‘default’ section in section list.
Values: 0 (no) or 1 (yes).
Default: 0.
The number of articles to display.
Default: 0 (no limit).
The number of articles to skip.
Default: 0.
sections="section name(s)"
Comma-separated list of section names to include in the list, displayed in specified order (unless overridden by the sort attribute).
Default: unset (all sections).
sort="sort value(s)"
How to sort resulting list.
rand() (random).
Each field in the textpattern database table can be used as a sort key.
When viewing a search results list, score (how well the search terms match the article) is available as an additional value.
Default: name asc.

Common presentational attributes

These attributes, which affect presentation, are shared by many tags. Note that default values can vary among tags.

Where value is an HTML element, specified without brackets (e.g. break="li") or some string to separate list items.
Default: br (but see break cross-reference for exceptions).
class="class name"
HTML class to apply to the wraptag attribute value.
Default: tag name or unset (see class cross-reference).
Label prepended to item.
Default: unset (but see label cross-reference for exceptions).
HTML element to wrap (markup) label, specified without brackets (e.g. labeltag="h3").
Default: unset.
HTML element to wrap (markup) list block, specified without brackets (e.g. wraptag="ul").
Default: unset (but see wraptag cross-reference for exceptions).


Example 1: Display a linked section list

<txp:section_list label="Sections" wraptag="p" break="br" />

Adds the label ‘Sections’ and wraps the output in a paragraph with each section on its own line.

Example 2: Display a styled section list

<txp:section_list wraptag="ul" break="li" />

Example 3: Set active class using the container tag

<txp:section_list wraptag="ul" break="">
    <li<txp:if_section name='<txp:section />'> class="active"></txp:if_section>>
        <txp:section title="1" link="1" />

This code will add class="active" to the <li> element around the currently viewed section in the list.

Other tags used: if_section, section.


Version 4.6.0

html_id, limit and offset attributes added.

Version 4.0.7

Can be used as a container tag.
form attribute added.

See something wrong in this document? Outdated info, a broken link, faulty code example, or whatever? Please write an issue and we’ll fix it.