Section list

On this page:

Syntax

<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:

<txp:section_list>
    ...contained statements...
</txp:section_list>

Attributes

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
default_title="text"
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.
include_default="boolean"
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.
Values:
css.
in_rss.
is_default.
name.
on_frontpage.
page.
rand() (random).
searchable.
title.
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.

break="value"
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="text"
Label prepended to item.
Default: unset (but see label cross-reference for exceptions).
labeltag="element"
HTML element to wrap (markup) label, specified without brackets (e.g. labeltag="h3").
Default: unset.
wraptag="element"
HTML element to wrap (markup) list block, specified without brackets (e.g. wraptag="ul").
Default: unset (but see wraptag cross-reference for exceptions).

Examples

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" />
    </li>
</txp:section_list>

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

Other tags used: if_section, section.

Genealogy

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.