Redirection plugin - any page containing nothing but a standard link will auto-redirect instantaneously
Redirection from one page to another. The redirecting page must contain nothing but a standard DokuWiki link to the target page (this may include a section anchor), OR a standard URL.
At wiki-internal redirection a small message pops up showing where you came from (using the standard msg() function). Click the page name in this message to go straight to the redirecting article in edit mode.
Updates:
<?php if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_mredirect extends DokuWiki_Action_Plugin { function register(&$controller){ $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'handle_start', array()); } function handle_start(&$event, $param){ global $ID; global $ACT; global $INFO; if ($ACT != 'show') return; if (!($INFO['exists'])) return; # don't try to read an article that doesn't exist if (preg_match('/^\[\[(([^]#]*)\#?([^]]*))\]\]$/',rawWiki($ID),$p)) { msg (sprintf('From: <a href="'.wl($ID,'do=edit').'">'.hsc($ID).'</a>')); if (strpos ($p[1], '://')) { $url = $p[1]; # link is URL already } else { $url = $p[2]; if ($INFO['namespace']) { # namespace support $url = $INFO['namespace'] . ':' . $url; } $url = wl($url); if ($p[3]) { # section support $check = false; # dummy variable for sectionID() $url .= '#' . sectionID($p[3], $check); } } idx_addPage($ID); # ensure fulltext search indexing of referrer article - to put it on the backlink page of target article send_redirect($url); } } } ?>
I find the plugin extremely useful and elegant, so thanks a lot for that. As I also like the useheading option of the wiki, I made the plugin compatible with it, or at least support it more.
This is the file from above with two changes:
Maybe this will be useful for someone else
I apologize if adding this section here broke some guideline of these plugin pages.
<?php if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_mredirect extends DokuWiki_Action_Plugin { function register(&$controller){ $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'handle_start', array()); } function handle_start(&$event, $param){ global $ID; global $ACT; global $INFO; if ($ACT != 'show') return; if (!($INFO['exists'])) return; # don't try to read an article that doesn't exist $text = rawWiki($ID); if(preg_match('/^([=]+[^=]+[=]+[\n]?)?\[\[([^]#]*)\#?([^]]*)\]\]$/',$text,$p)) { msg(sprintf('From: <a href="'.wl($ID,'do=edit').'">'.tpl_pagetitle($ID, true).'</a>')); $check = false; # dummy variable for sectionID $url = ($p[3] == '') ? wl($p[2]) : wl($p[2]) . '#' . sectionID($p[3], $check); idx_addPage($ID); # seemingly required for fulltext search indexing of the page, without which we won't show up on the$ send_redirect($url); } } } ?>