Adding Buttons to DokuWiki

What I Wanted

I wanted to add a “custom” button in dokuwiki, so my template would have a clearly indicated link to the legal information (“mentions légales” in French).

What I Discovered

  • one cannot use a call to tpl_button() because it only works for actions that are hard-coded into its select/case structure.
  • one can use


$name : important, this is concatenated to 'btn_' to use as a key in a lookup in the active lang file to obtain the label for the button.
* must therefore ensure the label key/value pair is in the lang file.
* probably must also ensure it ($name) doesn't have any whitespace in it.
$id : page_name (I think), like 'mentions_legales'
$akey : access key (probably not always useful nor obvious).
$params : array('do' ⇒ 'show')
$method='get' :
$tooltip='' : skip, to remain language independent?

What I Did

  1. Added the following statement to the list of buttons in my template sidebar: <li> <?php print html_btn('legal','mentions_legales','b',array('do' => 'show')); ?></li>
  2. Added key/value entries to lang.php for each of the languages I (might) use: EN, FR:
    • EN : $lang['btn_legal'] = 'Legal';
    • FR : $lang['btn_legal'] = 'Mentions Legales';


The labels added to lang.php will be lost when the file is overwritten at the next version change! It seems there are few options for “fixing” this:

  1. Lobby DokuWiki to include this btn_legal as a standard label in all language files
  2. Leave it as it is, and remember to re-enter the labels at each upgrade
  3. Make a plugin for this button, so the label can be separately maintained (seems like the wrong thing to do: overkill)
  4. Add a button_maker function and language files to the template: probably worth considering, if (1) fails.
doku_button.txt · Dernière modification: 2009/08/25 12:16 par suitable
Sauf mention contraire, le contenu de ce wiki est placé sous la licence suivante :CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki