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" v4.0.7+
Use specified form template to process each included section.
Default: unset.
html_id="id" v4.6.0+
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.
limit="integer" v4.6.0+
The number of articles to display.
Default: 0 (no limit).
offset="integer" v4.6.0+
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 the resulting section list. Specify a value from the ones below, followed by a space and then add either asc or desc to sort in ascending or descending order, respectively.
css (order by the Stylesheet in use by the Sections).
in_rss (order by whether the Sections are syndicatable or not).
on_frontpage (order by whether the Section allows articles on the front page or not).
page (order by the Page in use by the Sections).
rand() (random).
searchable (order by whether the Sections are searchable or not).
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).
breakby="integer" v4.7.0+
Used to group list items when separating by break. Possible values are lists of integers, like 2 (groups of 2 items) or 1,2 (alternate groups of 1 and 2 items).
Default: 1 (actually unset).
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.7.0

breakby attribute added.

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 open an issue and we’ll investigate.