DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:loadskin

Loadskin Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" unknown
  • 2023-04-04 "Jack Jackrum" yes
  • 2022-07-31 "Igor" yes
  • 2020-07-29 "Hogfather" 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
2017-01-15
Provides
Helper, Admin, Action
Repository
Source

Download and Installation

Search and install the plugin using the Extension Manager. 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. Pages not covered by one of these rules will still use the template specified by the template variable in the admin interface.

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)
allowInAdmin Allow template choice to persist in admin section 3)

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. But some templates might need a little help with user styles.

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
3)
By default the admin section would otherwise always show the one template you selected in the configuration manager. With this option enabled you can go to a page with a different template (or select one from the template switcher) and then go to the admin section and it will show in that template which means you can configure it.
plugin/loadskin.txt · Last modified: 2023-10-31 00:08 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki