DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:sectiontoggle

This is an old revision of the document!


sectiontoggle Plugin

Compatible with DokuWiki

  • 2018-04-22 "Greebo" yes
  • 2017-02-19 "Frusterick Manners" yes
  • 2016-06-26 "Elenor Of Tsort" unknown
  • 2015-08-10 "Detritus" yes

plugin Toggle sections open and closed by clicking on section headers; change templates where needed for phones and tablets

Last updated on
2019-07-28
Provides
Syntax
Repository
Source

Installation

:!: Requirements: This plugin requires jQuery and was originally designed for use with the DokuWiki Template. In its current form, it should work with any template.

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Examples/Usage

This plugin converts DokuWiki headers into toggles which open and close the sections immediately below them.

The plugin has undergone a number of revisions. In its current form, it 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.

When installed, the sections will initially be closed. 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. Headers without any text content below them will not be active and will not show the right arrow icon. 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, using the Configuration Manager, from being toggled.

Syntax

Toggle Buttons

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:

~~stoggle_buttons~~

These buttons will be hidden if toggling is disabled, as described below under Configuration.

Override

This feature enables you to create a container div for the page, in which case it is not necessary to set the name option for identifying the div which holds the wiki content. However, you must set the type option either to id or to class.

~~stoggle_openDIV~~
~~stoggle_closeDIV~~

You place the openDIV at the top of your wiki page and the closeDIV at the bottom. This will create a div with a section__toggle id. The entire wiki page will then be enclosed within this div. In all but the simplest of pages, these macros must be at the very top and the very bottom of your page.

Configuration

option options default description
platform all, mobile, none all 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

Notes on the Options

  • Platform
    • 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
    • The type is either an id or a class and the name the id or class attribute 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 templates.ini file, type must be set to none or 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_headers setting to omit selected headers from being converted to toggles.
  • mobile_alt
    • When platform is set to all or 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.
  • tablet_alt
    • If set to true the mobile_alt template will be used for tablets.

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 2.8.33.2)

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.

Example

The default template, which was the template that preceded the dokuwiki template, contains the following structure:

<div class="page">
  <!-- wikipage start -->
  <?php tpl_content()?>
  <!-- wikipage stop -->
</div>

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 page.

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 type and 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 none.

Preconfigured Templates

  1. 20cones
  2. adoradark
  3. arctictut
  4. bootstrap3
  5. dokucms
  6. flat
  7. greensteel
  8. kajukkk
  9. minima
  10. monochrome
  11. prsnl10
  12. sprintdoc
  13. twentyfifteen
  14. wallpaper
  15. white
  16. writr

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.

1)
The emphasis here is on may, i.e. possibly if you have large pages with many headers.
2)
2019-07-21
3)
this file will have to be created
plugin/sectiontoggle.1564406838.txt.gz · Last modified: 2019-07-29 15:27 by turnermm