DOKU_TPL
or DOKU_TPLINC
constantCompatible with DokuWiki
Change the skin/template/theme; admins can select templates per page/namespace, or users can select a template for the whole wiki
Similar to template_switcher, templateconfhelper
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).
This plugin can be used in two ways:
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.
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.
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).
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.
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.
A complete changelog is available here.
You can report any issues on the issue tracker and discuss anything on the separate discussion page.
DOKU_TPL
or DOKU_TPLINC
constantpreferUserChoice
config setting