Table of Contents
TPL_ACT_UNKNOWN
- Description:
- Output XHTML in the main DokuWiki window
- DefaultAction:
- Displays an "action unknown" message
- Preventable:
- yes
- Added:
- 2006-04-25
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; $event->preventDefault(); } public function performMyAction(Doku_Event $event, $param) { if($event->data != 'my_action') return; $event->preventDefault(); // output your XHTML content here }
See also
- Code related to this event used in any DokuWiki's files, plugins and templates