===== 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 %%html_btn($name,$id,$akey,$params,$method='get',$tooltip='')%% ^ $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 ==== - Added the following statement to the list of buttons in my template sidebar: %%
  • 'show')); ?>
  • %% - 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';'' === Problem! === 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: - Lobby DokuWiki to include this ''btn_legal'' as a standard label in all language files - Leave it as it is, and remember to re-enter the labels at each upgrade - Make a ''plugin'' for this button, so the label can be separately maintained (seems like the wrong thing to do: overkill) - Add a button_maker function and language files to the template: probably worth considering, if (1) fails.