Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
This event is signalled by tpl_get_action() in inc/template.php when properties of core actions are collected just before the properties are returned to functions tpl_button() or tpl_actionlink() that generate the html of a button or action link respectively with these properties. The handlers can use it to allow custom actions and to modify the properties of the action link.
Note: this event was removed from the DokuWiki Template at 2017-09-01 and replaced by MENU_ITEMS_ASSEMBLY. Other templates may still use this event.
The passed Doku_Event object has the field $data
.
The $data
field is an array with the entries:
edit
, recent
, login
, etc%s
placeholder in the caption
For handling of these properties see tpl_button()
or tpl_actionlink()
.
Use preventDefault()
to skip DokuWiki's default notice about unknown action.
If the default properties are fine for a custom action, calling preventDefault()
is enough to create your own link. But you could also modify the properties to your needs by changing the entries of the $data
array.
An use case is in combination with the pagetools/usertools/sitetools event.
<?php // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); /** * Add link to sitetool */ class action_plugin_example extends DokuWiki_Action_Plugin { /** * Register its handlers with the DokuWiki's event controller * * @param Doku_Event_Handler $controller */ public function register(Doku_Event_Handler $controller) { $controller->register_hook('TEMPLATE_SITETOOLS_DISPLAY', 'BEFORE', $this, 'add_menu_item'); $controller->register_hook('TPL_ACTION_GET', 'BEFORE', $this, 'define_action'); } /** * Add an item to sitetools * Can use `tpl_action()` because dokuwiki accepts 'youraction' by the define_action() handler below. * * @param Doku_Event $event * @param $param */ public function add_menu_item(Doku_Event $event, $param) { global $lang; $lang['btn_youraction'] = $this->getLang('youraction'); $event->data['items']['youraction'] = tpl_action('youraction', true, 'li', true); } /** * Accepts the 'youraction' action, while using the default action link properties. * Entries of $event->data can be modified eventually. * * @param Doku_Event $event * @param $param */ public function define_action(Doku_Event $event, $param) { if ($event->data['type'] != 'youraction') { return; } $event->preventDefault(); } }