register_hook('TPL_TOC_RENDER', 'BEFORE', $this, 'handle_toc'); } /** * Overwrite the TOC * @param Doku_Event $event * @param $param */ public function handle_toc(Doku_Event &$event, $param) { $wikiReq = ExecutionContext::getActualOrCreateFromEnv(); if ($wikiReq->getExecutingAction() !== "show") { // admin may also have toc return; } try { $toc = Toc::createForRequestedPage() ->getValue(); $event->data = $toc; } catch (ExceptionNotFound $e) { return; } } }