register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, '_handleConf'); //$controller->register_hook('MEDIAMANAGER_STARTED', 'BEFORE', $this, '_handleConf'); $controller->register_hook('DETAIL_STARTED', 'BEFORE', $this, '_handleConf'); //$controller->register_hook('TPL_CONTENT_DISPLAY', 'BEFORE', $this, '_handleContent', array()); // only needed for not yet up-to-date templates: $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, '_defineConstants'); //$controller->register_hook('MEDIAMANAGER_STARTED', 'AFTER', $this, '_defineConstants'); $controller->register_hook('DETAIL_STARTED', 'AFTER', $this, '_defineConstants'); } public function _defineConstants(Doku_Event $event, $param) { global $conf; // define Template baseURL if(!defined('DOKU_TPL')) define('DOKU_TPL', DOKU_BASE.'lib/tpl/'.$conf['template'].'/'); // define real Template directory if(!defined('DOKU_TPLINC')) define('DOKU_TPLINC', DOKU_INC.'lib/tpl/'.$conf['template'].'/'); } public function _handleConf(Doku_Event $event, $param) { global $ID, $ACT, $conf; $dataFile = wikiFN(cleanID($ID)); $fp = fopen($dataFile,"r"); $firstLine = fgets($fp,512); fclose($fp); preg_match('/~~USETHEME:(.*?)~~/', $firstLine, $match); $template = trim($match[1]); if($template) { $conf['template'] = $template; } } } // vim:ts=4:sw=4: