It's better when it's simple

User Tools

Site Tools



Output XHTML in the main DokuWiki window
Displays an "action unknown" message

Signaled by tpl_content() in inc/template.php, if it does not recognise the $ACT value. You can use this event to output XHTML for a custom $ACT1) value, which will be displayed in the main dokuwiki window - ie. where the wiki page would normally be displayed.

Passed Data

The passed Doku_Event object has the field $data.

$data is a string that contains the contents of the $ACT variable.

Add a BEFORE event handler to add your action. Check the $data field for correct action name. Also use an unique action name to avoid collisions.

Remember to use preventDefault() to prevent the “Failed to handle command” message. The use of stopPropagation() will stop checking the other registered event handlers.

The AFTER event handler is called after the (eventually prevented) default action. It cannot prevent the “Failed to handle command” message, that is only possible in BEFORE event handler by calling preventDefault(). So for normal use cases the AFTER event is not useful.

Note for implementors

Please note that if you want to display XHTML instead of the normal page content, you have to implement an additional event handler for ACTION_ACT_PREPROCESS. Otherwise the act_clean function will sanitize the action and your handler for TPL_ACT_UNKNOWN will never be called.

Example for handling “&do=my_action”:

  public function register(Doku_Event_Handler $controller) {
      $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE',  $this, 'allowMyAction');
      $controller->register_hook('TPL_ACT_UNKNOWN', 'BEFORE',  $this, 'performMyAction');
  public function allowMyAction(Doku_Event $event, $param) {
      if($event->data != 'my_action') return; 
  public function performMyAction(Doku_Event $event, $param) {
      if($event->data != 'my_action') return; 
      // output your XHTML content here

See also

devel/event/tpl_act_unknown.txt · Last modified: 2022-08-31 16:54 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