Table of Contents
Compatible with DokuWiki
- 2022-07-31 "Igor" yes
- 2020-07-29 "Hogfather" yes
- 2018-04-22 "Greebo" yes
- 2017-02-19 "Frusterick Manners" yes
This plugin converts DokuWiki headers into toggles which open and close the sections immediately below them.
To Configure or Not to Configure
The plugin will work out of the box with any template without any need for configuration. However, configuring the plugin as described in the section on Configuring for Mobile Devices may be useful for efficiency.1) A group of the most suitable templates for phones come pre-configured in the file templates.ini. You can also configure using the Configuration Manager.
To Toggle or Not to Toggle
When installed, the sections will initially be closed, except as described below under #Auto-Toggling. Clicking on a header will open the section immediately below the header. Clicking on it again will close the section. Using the two buttons described below, the user can open and close all the sections with a single click.
There are two situations where a toggled section will remain open when a page loads. This enables you to link to a section of a page and that section will be open when the page loads.
- When the url accessing the page contains a hash element referencing a page section. For instance:
[[wiki:dokuwiki#read_more]].This link will go to the
read more sectionof the page and the section will be open and ready for reading.
- When the
h_ini_openoption is set. For instance:
Welcome to your new DokuWiki;;DokuWiki Intro;;Read More.
With this setting, when
wiki:dokuwikiloads, two sections will remain open: DokuWiki Intro and Read More and when
wiki:welcomeloads the topmost Welcome to your new DokuWiki will be open.
The Dokuwiki table of contents also benefits from auto toggling. That is, when you click on a heading in the table of contents, not only will the page be directed to the heading, but the section will toggle open.
Headers without any text content below them will not be active and will not show the right arrow icon. They will simply be standard headers and not toggles. In addition, in the Configuration Manager, you can choose to prevent selected headers from being toggled, as in the sample page below. There the End of Page header is an
h5, which is excluded from being toggled by the
headers configuration option.
Inserting the following into the page will create two buttons, one which will open all the sections with one click and one which will close them:
These buttons will be hidden if toggling is disabled using the
suspend option, as described below under Configuration.
Limiting toggles to a section of the page
The following two macros will mark the start and end of an enclosing
DIV within which headers will be converted to toggles. Headers elsewhere on the page will not have toggles attached to them.
These should not cross
DIV boundaries. I.E.
DIV 1 DIV section__toggle Div 1 closed DIV section__toggle closed.
|platform||all, mobile, none||mobile||Selects the platform(s) on which to implement section toggling.|
|type||none,id,class||none||Indicates whether the div which encloses the affected headers is identified by a class or an id.|
|name||Name of the class or id which identifies the enclosing div.|
|headers||h1-h6||h4||Smallest header to activate as toggle. All headers between h1 and this setting will be toggles.|
|suspend||1,0||0||If set to true the plugin will be inactivated and no toggles will be set.|
|xcl_headers||Checkboxes to select headers which should not be set as toggles|
|mobile_alt||An alternate template installed for phones, in case your preferred template does not support phones.|
|tablet_alt||1,0||0||Use the alternate template for tablets|
|tablet_toggle||1,0||0||Use toggles on tablets as well as phones|
|xcl_ns||Comma separated list of namespaces to be excluded from toggles, without initial or final colons (i.e. name:space , not :name:space: )|
|xcl_pg||Comma separated list of page ids to be excluded from toggles (without initial colons, i.e page:id, not :page:id )|
|incl_ns|| Comma separated list of namespace ids where toggles should appear (without initial colons). Takes precedence over
|incl_pg|| Comma separated list of page ids where toggles should appear (without initial colons). Takes precedence over
|h_ini_open|| List of header texts, separated by double semi-colons, where toggles should stay open when the page loads, i.e.
header-text;;header-text;;. . .
|toc_toggle||true/false||false||When true, clicking on an entry in the TOC will not toggle the selected header but will, as in the default Douwiki configuration, direct the cursor to the header's page location.|
|start_open||true/false||false||Load page into browser with all toggles open (they can then be closed and opened as usual)|
Notes on the Options
all: section toggling will appear on all platforms, mobile and standard desktop systems
mobile: mobile only, desktops are excluded
none: toggling is disabled on all platforms.
- Name and Type
typeis either an id or a class, and the
nameis the id or class name of the divs which govern the headers. If you are using the DokuWiki template or one of the templates listed in templates.ini, the plugin automatically detects the template and will use the appropriate settings. In the case of the
typemust be set to
noneor the file will be ignored.
- Headers and xcl_headers
- The headers option selects the smallest header to be converted to a toggle. If you choose h6, all headers between h1 and h6 will be converted to toggles. You can, however, use the
xcl_headerssetting to omit selected headers from being converted to toggles. In this case, the section below the header will remain permanently visible.
platformis set to
mobile, this option enables you to switch to an alternate template that supports phones, in the event that your preferred template does not. If your preferred template does support phones, then set this option to blank. A check is made to insure that that alternate template is correctly installed, and if not the main template is used.
- If set to true the
mobile_alttemplate will be used for tablets.
- This option will not apply to mobile devices or to logged in users without edit permission.
When the toggle buttons are included on a page, they will not display if the platform is excluded from section toggling. So, if you want toggling only on mobile devices, you can still include these buttons on your page but they will not display on standard desktop systems.
Detecting the Platform
When the DokuWiki template is in use, this plugin uses the template's platform recognition facility. For other templates, it uses the
Mobile_Detect class from http://mobiledetect.net. You can go to that site to update the detection software. Currently, we are at version 18.104.22.168)
Configuring for Mobile Devices
The example below is for manual configuration, using the plugin's options. Most templates from Weatherwax on which are usable with phones are pre-configured in templates.ini. That is, like the current
dokuwiki template, they have been designed to accommodate the smaller sizes of phones. What works with a phone will work with a tablet. But there are quite a few templates which will not work with phones that do work on tablets.
default template, which was the template that preceded the
dokuwiki template, contains the following structure:
The wiki page is included in the div which is defined by the class named
page. To use this template, then, you would set type to
class and name to
If you are using the dokuwiki template, the default settings for type and name will take precedence over these configuration settings, as they are hard-coded into the plugin. If you want to use the dokuwiki template with changes to its structure, then you must give it a different template name.
Templates.ini: Preconfigured Templates
The plugin comes with a group of preconfigured templates. If your template is one of these, then it will work right out of the box and your plugin will read the
name configuration values from an ini file named templates.ini, which is found in the root directory of the plugin. For this to work, the
type option must be set to
none in the sectiontoggle section of the Configuration Manager. This is only an issue if you have already used the Configuration Manager to set up the plugin for another template, since the plugin comes with
type already set to
These templates have been chosen for usability and popularity, covering a period of six years to seven years–Greebo through Weatherwax compatibles. Some popular templates like monobook are not suitable for phones and so have been omitted from this list. And some nice templates do not work as alternates, i.e. as
mobile_alt, because they haven't been kept up-to-date. No doubt there are good early templates that can still be used. So, this list may grow, as more templates are tested. If you would like to have an entry added to the the ini file, open an issue on github. In the meantime you can add your choice to plugins/sectiontoggle/templates.ini.local3), since additions to templates.ini may be overwritten on upgrades. The format for an entry in templates.ini.local is:
[[template name]] type = id or class name = id or class name
Or, you can configure your template manually, as shown in the example.