Access the list of named sections in a topic
Description
This plugin lets you access the list of sections in a topic defined by
VarSTARTSECTION and
VarENDSECTION.
Syntax
%SECTIONLIST{"<topic>" ... <params>}%
returns a list of names of the sections
Parameter |
Description |
Default |
"..." or topic="..." |
topic to list the sections of |
current topic |
rev="..." |
revision of the topic |
latest revision |
type="..." |
section type to extract, can be section , expandvariables , include , templateonly or all |
all |
header="..." |
header string to prefix the result |
|
format="..." |
format for each list element |
$name |
footer="..." |
footer string to appended to the result |
|
separator="..." |
string to separate list elements in the result |
, |
sort="on/off" |
boolean flag to enable sorting results by section name |
off |
reverse="on/off" |
boolean flag to invert the order of the result |
off |
include="..." |
regular expression to filter the result list |
|
exclude="..." |
regular expression to filter the result list |
|
limit="..." |
maximum number of sections to return |
all |
skip="..." |
number of items in the list of sections to skip while rendering the outout |
0 |
The
format
parameter can take the following variables:
-
$name
the name of the current section
-
$type
the type
-
$index
index of the current item in the result list
-
$count
list size of the result list
-
$total
total number of sections in the topic
-
$web
web name of the topic currently being processed
-
$topic
topic name of the topic currently being processed
-
$rev
revision of the current topic
- standard format tokens such as
$n
and $percnt
etc
Examples
a comma separated list of sections in the current topic:
You type:
%STARTSECTION{"example 1"}%
%SECTIONLIST%
%ENDSECTION{"example 1"}%
You get (if installed):
example 1, example 2
render an unordered list of links to view the named section
You type:
%STARTSECTION{"example 2"}%
%SECTIONLIST{
format=" * <a href='%SCRIPTURLPATH{"view"}%/$web/$topic?skin=text&rev=%URLPARAM{"rev"}%§ion=$name'>$name</a>"
separator="$n"
}%
%ENDSECTION{"example 2"}%
You get (if installed):
Installation Instructions
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button.
Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will
not show up in the
search results.
You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
cd /path/to/foswiki
perl tools/extension_installer <NameOfExtension> install
If you have any problems, or if the extension isn't available in
configure
, then you can still install manually from the command-line. See
https://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Dependencies
None
Change History
26 Jan 2024 |
added $rev token |
27 Mar 2018 |
initial version |