Extension:NamespacePaths

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
NamespacePaths

Release status: stable

Description Allows custom article paths to be mapped to namespaces of the wiki, e.g. mapping pages like Help:A to /help/Page instead of /wiki/Help:Page.
Author(s) Daniel Friesen @ Redwerks (Dantmantalk)
Latest version 1.0.1 (2011-11-26)
MediaWiki 1.19+
Database changes No
License GNU General Public License 2.0 or later
Download
Hooks used
WebRequestPathInfoRouter

GetLocalURL::Article

Translate the NamespacePaths extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

NamespacePaths extends custom article paths to allow namespaces to be mapped to extra paths separate from the article path. For example mapping the help namespace to /help/$1 so pages like Help:Contents go to /help/Contents.

Note that NamespacePaths requires hooks introduced in MediaWiki which as of writing is still alpha, for now if you want to use on a production wiki you can try to apply the changes made in r94373 to your version of MediaWiki and you won't have to re-patch when you upgrade to 1.19.

The NamespacePaths extension is rather simple, you can copy the important functional pieces of the code into your LocalSettings.php and use it as a base on how to add extra article paths to your wiki.

Installation[edit | edit source]

  1. Download a snapshot and extract it to your extensions directory. Choose the version that matches your version of MediaWiki.
  2. Add
    require_once( "$IP/extensions/NamespacePaths/NamespacePaths.php" );
    to the bottom of LocalSettings.php.
  3. Configure the $wgNamespacePaths with the paths you want to use for namespaces, the key is the namespace id (you can use the NS_ constants), and the value is a $wgArticlePath style string like "/help/$1".
  4. Configure your webserver to pass the extra paths to MediaWiki. Consult the short url documentation you set the article paths for your wiki and extend it to map the extra paths to index.php.
    • Note that you don't want to try mapping things to /index.php?title=$1, doing so will break the paths. If you just make sure that /index.php is run for these extra article paths as long as your webserver sets REQUEST_URI correctly the extension will take it from there and extract the correct title on it's own.
  5. Installation can now be verified through Special:Version of your wiki.