DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:loadskin

Loadskin Plugin

Compatible with DokuWiki

  • 2014-09-29 "Hrun" yes
  • 2014-05-05 "Ponder Stibbons" yes
  • 2013-12-08 "Binky" yes
  • 2013-05-10 "Weatherwax" yes

plugin Change the skin/template/theme; admins can select templates per page/namespace, or users can select a template for the whole wiki

Last updated on
2015-05-05
Provides
Helper, Admin, Action
Repository
Source

Tagged with skin, template, theme

Download and Installation

Download and install the plugin using the Plugin Manager using the URL given above. Refer to Plugins on how to install plugins manually.

:!: Important :!: If your DokuWiki is older than Angua or if the templates you are using it with are not up-to-date1), you have to make the following small change to DokuWiki's source code. Otherwise you might get partially (or completely) blank pages.

Remove (or comment) the following lines in <dokuwiki>/inc/init.php:

// DEPRECATED, use tpl_basedir() instead
if(!defined('DOKU_TPL')) define('DOKU_TPL',
        DOKU_BASE.'lib/tpl/'.$conf['template'].'/');
 
// DEPRECATED, use tpl_incdir() instead
if(!defined('DOKU_TPLINC')) define('DOKU_TPLINC',
        DOKU_INC.'lib/tpl/'.$conf['template'].'/');

Fixing templates is easy. Just replace every DOKU_TPLINC with tpl_incdir() and every DOKU_TPL with tpl_basedir() (see their deprecation).

Usage

This plugin can be used in two ways:

  • Admins can specify different templates for different wiki pages or namespaces.
  • Or users can use a select box for the whole wiki.

Although you can use both ways together, it is advisable to only use one method or the other. Because otherwise you need to decide2) which choice is the preferred one.

Admin way: Specify templates per namespace/page

The plugin comes with an admin component you'll find in the admin menu. Use it to specify the templates to be used for different wiki pages or namespaces.

User way: Select template for whole wiki

Alternatively the plugin can let the user choose the template for the whole wiki through a template switcher. Your users will need to allow cookies for that (otherwise the template won't switch permanently).

Configuration

automaticOutput Automatically output the template switcher on every page (turn this off if you don't want to show the template switcher or want to put it somewhere else)
excludeTemplates Exclude templates from template switcher (comma-separated list)
mobileSwitch Show mobile template switcher (with only 1 normal and 1 mobile template)?
mobileTemplate Mobile template (if showing mobile template switcher)
preferUserChoice Prefer user's template choice over admin's choice (turn this off to let the admin's choice have the preference)
inheritInTranslations Inherit template choice per namespace inside a language namespace (when using the translation plugin)

The template switcher is automatically put before the wiki content. If you like to put it somewhere else (e.g. near the login button or into the sidebar), you need to switch automaticOutput and put the following code into your template to wherever you like to display it:

<?php
    $loadskinHelper = plugin_load('action', 'loadskin')->loadHelper('loadskin', true);
    echo $loadskinHelper->showTemplateSwitcher();
?>

The styling which come with the plugin will suit most templates when it's automatically put before the wiki content. One exception is the new default 'dokuwiki' template. You should add the following to the template's styles to make it not overlap with the TOC:

.dokuwiki .plugin_loadskin {
    margin: -1em -1em 2em 0;
}
[dir=rtl] .dokuwiki .plugin_loadskin {
    margin: -1em 0 2em -1em;
}

Cookies

This plugin doesn't set any new cookies, but uses the DOKU_PREFS cookie which the DokuWiki core already uses. If a user uses the template switcher, it sets loadskinTpl to the chosen template. It also sets loadskinOrig to the original template which would show if nothing had been chosen.

Changelog

Discussion

You can report any issues on the issue tracker and discuss anything on the separate discussion page.

1) i.e. if a template's code contains the DOKU_TPL or DOKU_TPLINC constant
2) with the preferUserChoice config setting
plugin/loadskin.txt · Last modified: 2015-05-05 02:22 by ach