Extension:Redirect Anchor
From MediaWiki.org
|
Redirect Anchor Release status: stable |
|
|---|---|
| Implementation | Extended syntax |
| Description | Enable redirects to particular sections of articles. |
| Author(s) | Emiller |
| Version | n/a (2006-05-09) |
| MediaWiki | 1.6.x |
| Download | see below |
| Hooks used | |
Note: Redirecting to section is now available as a core feature, so this extension is deprecated.
I basically ripped this off of something I read in the Bugzilla, but cleaned it up a touch to be compatible with m:User:Emiller/GoogleMapsExtension. This extension allows #REDIRECT directives to point to particular sections of articles, e.g. #REDIRECT [[Games#Broomball]]. It uses JavaScript, so it won't work in ancient web browsers. Anyway, paste this into extensions/RedirectAnchor.php:
<?php $wgHooks["ArticleViewRedirect"][] = 'wfRedirectJump'; $wgHooks['OutputPageBeforeHTML'][] = 'wfRedirectInjectJS'; function wfRedirectInjectJS(&$parser, &$text) { global $wgRedirectAnchorInjection; if ($wgRedirectAnchorInjection) { $text .= $wgRedirectAnchorInjection; } } function wfRedirectJump (&$array) { global $wgHooks, $wgRedirectAnchorInjection, $wgJsMimeType; $section = $array->getTitle()->getFragment(); if($section) { $inject = "<script type=\"{$wgJsMimeType}\"><nowiki><!--\n//<!CDATA[\n" ."window.location.hash = '".preg_replace("/%/", ".", urlencode($section))."';" ."\n//-->\n</nowiki></script>\n"; $wgRedirectAnchorInjection = $inject; } return true; } ?>
And then add this to LocalSettings.php:
require( "extensions/RedirectAnchor.php" );

