Extension:NamespacePaths

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.svg
NamespacePaths

Release status:Extension status stable

DescriptionTemplate:Extension#description Allows custom article paths to be mapped to namespaces of the wiki
Author(s)Template:Extension#username Daniel Friesen @ Redwerks (Dantmantalk)
Latest versionTemplate:Extension#version 1.1.0 (2017-10-30)
MediaWikiTemplate:Extension#mediawiki 1.23+
PHPTemplate:Extension#php 5.4+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download
ParametersTemplate:Extension#parameters
$wgNamespacePaths
Hooks usedTemplate:Extension#hook
WebRequestPathInfoRouterManual:Hooks/WebRequestPathInfoRouter
GetLocalURL::ArticleManual:Hooks/GetLocalURL::Article

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

Check usage and version matrix.

The NamespacePaths extension 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.

Installation[edit]

  • Download and place the file(s) in a directory called NamespacePaths in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/NamespacePaths/NamespacePaths.php";
    
  1. 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".
  2. 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: 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.
  • YesY Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.