Help talk:Custom namespaces

From Meta, a Wikimedia project coordination wiki


This article states:

  1. Goto /includes/DefaultSettings.php and copy the variables $wgExtraNamespaces, $wgNamespacesWithSubpages, and $wgNamespacesToBeSearchedDefault into LocalSettings.php

....but I do not see these variables in the file mentioned.

I got custom namespaces working on my wiki. However, these directions seem incorrect. $wgExtraNamespaces does nothing... To make this work, i had to do the following:
Add to includes/Namespace.php: (in 1.5.3 that is in the includes/Defines.php)
define("NS_FOO", 100);
define("NS_FOO_TALK", 101);
Add to languages/Language.php in $wgNamespaceNamesEn array:
NS_FOO => 'Foo',
NS_FOO_TALK => 'Foo_talk'
The rest of the directions seem to work fine.
--Ryan lane 14:42, 23 Nov 2004 (UTC)

Agreed - on 1.5.6 I also needed to make the above edits to get custom namespaces working. -- 19:05, 26 February 2006 (UTC)[reply]

Customizing a custom namespace?[edit]

Is it possible to customize a custom namespace, so that all pages, and new pages within that namespace will contain a particular template? --Magick 10:38, 11 November 2006 (UTC)[reply]

It works for me[edit]

Which version are you using? It works for me on version 1.3.8. Check if your language/Language.php got a line:

if(isset($wgExtraNamespaces)) {

The above statements should add the namespaces defined in $wgExtraNamespaces to $wgNamespaceNamesEn. If you use another language, you should add the statements in corresponding language/Languagelang.php .

Roy Chan 03:14, 9 Dec 2004 (UTC)

Expected behavior[edit]

I have the following installed: - Windows XP Pro - Apache: 2.0.52 - MySQL: 4.0.23 - PHP: 4.3.10 - MediaWiki 1.3.10

I followed the instructions for adding custom namespaces, but I can't tell that anything is changed. My bigger concern is that there doesn't seem to be anything from keeping the users from adding pseudo-custom namespaces just by sticking in a colon in the link (NSFOO:Page).

The behavior I was kind of expecting was that if I added NSAPP1 as a custom namespace and added a new link to NSAPP1:Page, it would at least validate that NSAPP1 is valid and exists. However, it seems someone could enter/mis-type NSAPP1:Page as NSAP1:Page1 and there is no validation to check whether NSAP1 is valid or exists and then we would have two separate pages.

So, if there is no validation and nothing really seems to change in the UI to indicate that you are using a valid custom namespace, and you can extemporaneously use 'custom' namespaces just be sticking something in before the colon, why go through the steps on these pages? What behavior should I be expecting from custom namespaces?


See Help:Namespace.--Patrick 22:33, 18 Feb 2005 (UTC)

I just created a new namespace. How am I supposed to create pages within that namespace, and how do I access them? What's the url for a new namespace?

I made a mistake[edit]

I misread the article and edited DefaultSettings.php, now I'm getting a MySQL error. Is there any way I can fix this? I changed the file back to the way it was and I still got the error. (nevermind, I uploaded the original and it fixed the problem)

Custom namespaces and anonymous user searching[edit]

mediawiki 1.4.2 running PHP 4.3.2, Apache 1.3.29, MySQL 4.1.9 on Mac OS 10.3.8

After setting up custom namespaces by adding the $wgExtraNamespaces array to LocalSettings.php, I wanted to be able to search the custom namespaces by default.

I was having trouble getting the $wgNamespacesToBeSearchedDefault array (also added to LocalSettings.php from DefaultSettings.php) to actually change the defaults. It looked like it worked for registered users, but not for anonymous users. I don't know if anyone else wants the same behavior, but since I've wasted a couple hours tracking it down, I thought I'd post it here:

Change the following in includes/Users.php: Line 185, function loadDefaultFromLanguage():

function loadDefaultFromLanguage(){
   $this->mOptions = User::getDefaultOptions();


function loadDefaultFromLanguage(){
   $this->mOptions = array_merge($this->mOptions, User::getDefaultOptions());

Hope this helps someone else!

Adam Johnson

Adam... thanks VERY much for putting this info up here. I would have never figured that out on my own (I'm ok with changing variables, but a function change like this is out of my league). Anyway, I am running version 1.4.10 as a Debian package (so it's older than the latest version). This was the only way to get this working (after hours of suffering). I have version 1.5 running on a different machine, and it does not need this special modification (the regualr instructions work fine)... so I guess they added this fix into more recent versions.

Thanks, Ryan

Expand discussion[edit]

I can't really see what this page is trying to tell me. No doubt I can try to understand it, but I have no idea what "namespace" really is. Can we talk about that more? 12:54, 3 Jul 2005 (UTC)

New pages within a new namespace[edit]

I just created a new namespace. How am I supposed to create pages within that namespace, and how do I access them? What's the url for a new namespace? I'm kind of lost here, and Help doesn't help ;-)

The Namespace is a "place" wher your article can have the same name as another article in another namespace. e.g. the article "Help:Foo"is different from the article "Foo" (note that for the Main namespace, you don't type Main:Foo ...) or from "Some_Namespace:Foo".

As you can see, you can access an article in a different namespace by typing after index.php/Some_Custom_Namespace:Some_New_Article in the adress bar. Note that if you haven't yet create the "Some_Custom_Namespace" namespace, it will createin fact an article in the main namespace called "Some_Custom_Namespace:Some_New_Article".

Namespaces are usefull because you can have similar article but for different means. And also because namespaces can have different behaviors (look for example at the differences when you have an article in Main:, Category: and Image:)

User:Textorisj 17:36, 29 August 2005 (UTC)[reply]

List of namespaces[edit]

Is there any way to get the list of namespaces through the regular web interface? Bovlb 01:03, 7 September 2005 (UTC)[reply]

Yes, see Help:Namespace#Custom_namespaces.--Patrick 09:48, 7 September 2005 (UTC)[reply]

Custom Namespaces and User Privileges[edit]

Is it possible to set up a custom namespace and restrict that namespace to users of a certain level? An example: I want to create an Admin section where Admins can discuss issues, but regular Users can't see the discussion. Of course, I could set up a second Wiki for admin ... but I'd like to do it all within the one Wiki. --Justin Eiler 18:37, 7 September 2005 (UTC)[reply]

I would be interested in this too. --Wolf530 21:22, 14 January 2006 (UTC)[reply]
take a look on this NamespacePermissions Extension -- 19:07, 13 February 2007 (UTC)[reply]

New Custom Namespace but artilces already exist[edit]

Does anyone know if it's OK to create a "proper" custom namespace after articles have already been created in there, i.e. Foo:bar exist's and then some goes through the setps here and creates namespace foo, does the world come crashing down or do the namespacey things just work (useing variable like {{{PAGENAME}}} for instance), do existing artilces get deleted, does it only work for newly created article? Cheers-- 23:14, 29 September 2005 (UTC)[reply]

What's the use of namespace?[edit]

I expected the namespace feature to help create a separation of context between two same concepts.

For example, being able to have a faq in two contexts: a and b: (ie: a:faq and b:faq).

I understand the need to have two fully qualified names, but my understanding is that, once in a context (eg: a), I should be able to use "faq" and see the a:faq page.

Being in the A context, I should be able to see a page with a title "faq" and not "a:faq" (if I choose so).

Now the way I see it work on my system is that if I want to see the a:faq page, then I need to name it explicitly, and it displays explicitly. Then, IMO, it defeats the very notion: If I want/need to be explicit, why not just be so (ie: without any specific mechanism)? 00:27, 12 October 2005 (UTC)[reply]

You can e.g. see Recent changes and Allpages for a namespace, see Help:Namespace.--Patrick 10:52, 12 October 2005 (UTC)[reply]
oki, that's a cool use... tho I expected more intelligence from the system concerning this "context" feature. From what I read onsome other places, I'm not the only one to expect this. -- 15:45, 13 October 2005 (UTC)[reply]
Also: By trying the features you pointed out to me, I've noticed that using the "a:faq" notation doesn't make a exist as a namespace, it seems one has to define it in a file manually (at the wiki's design time).
So beside regrouping articles for a search page (recentchange/users/...), it seems there isn't much to expect from namespaces, right?
Maybe I'm trying to use the namespace for something it wasn't thought to be in the first place. Maybe there is another completely different system for what I want to achieve (ie: organising my data in somekind of tree of "folder" fashion - the default being a "complete network" fashion, with the potential problem of the uniqueness of names [right now I have that specific problem, in my personal wiki, of having two "software list" page, one dedicated to the world of PCB design and another one dedicated to CAD... depending on the context, I wish the users to see one list or the other, but not both])  ? -- 16:22, 13 October 2005 (UTC)[reply]
You can also set up several projects, with interwiki linking and common login.--Patrick 00:03, 14 October 2005 (UTC)[reply]
Patrick, I can't find documentation on "project". Can you suggest something? Dilger 20:42, 23 October 2005 (UTC)[reply]
I mean a separate MediaWiki installation, like those listed in Complete list of Wikimedia projects. However, they have no common login. Wikicities: has that, you could ask there how that is done.--Patrick 23:31, 23 October 2005 (UTC)[reply]

Something else to note. Seperate Namespaces, allows sysop ability to control various items:
(System Admin options in LocalSettings.php)

  1. Permissions per namespace per permission group. (Might only be available in ver 1.5)
    • (I.e. some users can only 'read' some namespaces, while others can 'edit/modify')
  2. Some Namespaces can be searched by default.
  3. Some Namespaces can be listed to be 'searchable' option.
  4. Allow subpages in some namespaces while not in others.

--IainDavidson 08:10, 8 November 2005 (UTC)[reply]

Subpages true for all Namespaces ?[edit]

Question?: I would like to activate subpages for all Namespaces in the wiki.

Possible answer:

$wgNamespacesWithSubpages = true;

Question?: I would like to activate subpages for all Namespaces in the wiki.

Possible answer:

$wgNamespacesToBeSearchedDefault = true;

Would the above actually safely work ? If not, what's the best answer? (Then add it in the article itself.:) --IainDavidson 08:30, 8 November 2005 (UTC)[reply]

namespace is of type int[edit]

from Help talk:Namespace regards Gangleri 00:06, 13 January 2006 (UTC)[reply]

from #mediawiki:

brion gangleri: it's an 'int' field now, so in theory probably 2^31-1 is the maximum namespace value
2^31-1 is 2.147.483.647 regards Gangleri | Th | T 21:31, 2 December 2005 (UTC)[reply]

Internal Namespace linking not working[edit]

I have a custom namespace set up in my wiki but like other folks here I can't seem to get internal linking (without the prefix) to work. The namespace seems to be set up right through local settings and such. It shows up check in the search under special:preferences and when I use the Help talk on the pages in question they return the proper namespace. Yet using simple linking doesn't link to the page with that title in the namespace. Any ideas or other places I can look for help on this? I did use the instructions under ... setting btw and this did nothing for me. --Streamweaver 04:01, 14 March 2006 (UTC)[reply]

Problem: 1.7.1 custom namespace does not work[edit]

In mediawiki 1.7.1

Before set namespace: the [[cutm:test]] tag works fine.

But after set this: $wgExtraNamespaces = array(50 => "Cutm", 51 => "Cutm_talk");

the [[cutm:test]] tag will link to


And I use User:Ryan 's solution, it works fine...

--Chlon 01:20, 17 July 2006 (UTC)[reply]

1.6.8 - absolutely no result.[edit]

I followed the three steps clearly. I also tried a few variations with commas, other php syntax and looked around the net. I can find no info on this and it appears that noone has looked at this thing for a few wikiversions so I'm wondering if there is a new procedure for 1.68 or other newer wiki versions. Right now all of this does not add a namespace at all. Nothin. Help? TheHYPO 06:58, 7 August 2006 (UTC)[reply]

I had the same problem. Double check that you have not inserted anything above "require_once( 'includes/DefaultSettings.php' )" in LocalSettings.php. In my case, I was setting $wgExtraNamespaces above this and the DefaultSettings were loading afterward and resetting the variable. -- Troll 12:55, 25 August 2006 (UTC)

Problems with the search[edit]

Before we have short article names like ICQ, MSN 3 Letters, these articles can be found via the search, now we have create a new Namespace "Plugin" and move the articles with 3 letters to this, now "Plugin:ICQ" the search cant find them any longer, the same behavior not happend for Plugin:Ping (4 letters) --Lastwebpage 08:58, 28 August 2006 (UTC)[reply]

exclude namespace from link title?[edit]

Is there a way to exclude the namespace from the link title? I have a mediawiki installation where I make a lot of use of custom namespaces, and I get really sick of typing: [[Foo:bar|bar]] [[Foo:baz|baz]] [[Foo:something else|something else]] [[Foo:your mother was a hamster and your father smelt of eldarberries|your mother was a hamster and your father smelt of eldarberries]]''' Bob the Hamster 15:32, 12 October 2006 (UTC)[reply]

See Help:Piped_link#Pipe_trick.--Patrick 22:44, 12 October 2006 (UTC)[reply]

works for me[edit]

i don't know why people were having truble with this. i followed the instructions (mediawiki 1.6.8. i know there is a newer one, but my host doesn't have PHP 5 yet) and it worked like a charm. 23:13, 21 October 2006 (UTC)

How to custom namespaces in Chinese language?[edit]

I followed the instruction and succeeded to customize namespace. But when I use tradition chinese namespace, it just display incorrect. Is there any solution? --Quench 08:58, 29 November 2006 (UTC)[reply]

Default Search settings don't work[edit]

Apache 2.2.2, MySQL 5.0.21, PHP 5.2 MediaWiki 1.8 on Windows XP, SP2

Did the steps as detailed in the article, namespaces exist fine, subpages work fine, search default settings don't work, even after restarting (I know, it said that's not necessary). What could be the problem? Thanks for help 10:44, 8 December 2006 (UTC)[reply]

As admin user, go to Special Pages->Preferences->Search tab. Select the default namespaces to search. --Bpang 00:49, 18 December 2006 (UTC)[reply]

This works for that one user but not for everyone...I have the same setup as above with now luck just changing my preferances. --Jmaas 19:36, 23 January 2007 (UTC)[reply]

Simple error when copying from DefaultSettings.php[edit]

I wasn't paying close enough attention when copying $wgExtraNamespaces from DefaultSettings.php

$wgExtraNamespaces = array(100 => "Foo", 101 => "Foo_talk" );

/*$wgExtraNamespaces = NULL;*/

Make sure you uncomment the array definition and comment out or delete the line that sets $wgExtraNamespaces to NULL.

I over-looked it, maybe you did, too.

--Bpang 22:57, 17 December 2006 (UTC)[reply]

Yup, I just did...and couldn't figure out why my new NS's where not displaying --ChuckMcB 19:43, 8 March 2007 (UTC)[reply]

moving pages in a custom namespace[edit]

I am trying to develop my own wiki site and I created a custom namespace. When trying to move a page in that namespace, the talk page is not moved with it (even though Move associated talk page is checked). am I doing something wrong? Nazly.elshazly 11:28, 20 January 2007 (UTC)[reply]

custom namespaces with special characters[edit]

How to set up a custom namespace containing a special character (like "ó")?

citing brion vibber

First, use the real ó character, not ó

Second, save the file as UTF-8. 

Third, make sure there isn't a hidden "BOM" character at the start of
the file after you save it -- Windows Notepad will insert this when you
save a file as Unicode, but it will mess up some things (broken RSS
feeds, broken caching, possibly visible error messages). I recommend
using a programming editor such as jEdit which allows saving as UTF-8
without the BOM character.

(Sorry for the BOM problems, but this is an issue with how PHP handles

> The meta instruction says "Do not save LocalSettings.php as Unicode,
> because PHP cannot handle it" - so is there any possibility to get
> things done?

Some editors such as Notepad mark simply "Unicode" for UTF-16, a form of
Unicode text which is basically wildly incompatible with everything. ;)
Most Internet-friendly Unicode usage is done in the UTF-8 encoding.

different categories in custom namespaces[edit]

Hello, I just wonder if it's possible to put any catogory under custom namespace like this:




and every category will be different. Is it possible or it's nonsence? :) thx -- 18:48, 13 February 2007 (UTC)[reply]

That would not work, but you can use Category:Image talk:Abc etc.--Patrick 02:34, 14 February 2007 (UTC)[reply]

Error moving page from custom namespace[edit]


I have a number of custom namespaces defined in my LocalSettings.php file.


I created a document in 'Content Management' namespace called 'my overview' i.e. Content Management:my overview

I then moved it to the 'User Guides' namespace i.e. User Guides:my overview

BUT when I go the page now, the content is displayed in the discussion tab, and the first tab still displays Content Management.

How can I fix this ???

Any help would be great.

many thanks


- Windows XP - Apache 2.2.3 - php 5.2.0 - Mediawiki 1.9.2 - MySQL 5.0.24a

Markw21 21:58, 14 February 2007 (GMT)

Tab title of a custom namespace[edit]

Q: I've installed the version 1.6.8 (as a scientific dictionary site). I've defined some namespaces called "en", "fr", "tr", etc. and they work properly. However I'd like to have the tab title different, i.e. "english term", "french term", "turkish term", ...

In message.php, there are keys corresponding to their tab title, e.g. I editted main namespace's tab title as:

'article' => 'terim' # 'term' in turkish.

However, I don't know the key of my custom namespace. I tried '101', 101, 'en', etc. but it didnt work. What should I do?--Oktay D. 12:11, 31 March 2007 (UTC)[reply]

Skipping namespace name in category listing[edit]

I have custom namespaces set up. When I view the list of pages in a category that includes items from a namespace, the listing is alphabetized by the namespace name (i.e., all pages in the "Foo" namespace are alphabetized under "F"). I have noticed that on some wikis, this is not the case (see Wikia's Help category); is there a setting or customization that would force the category listing page to skip the namespace name when grouping the pages alphabetically?

- AtlasTC 20:42, 19 June 2007 (UTC)[reply]

See Help:Category#Sort_key.--Patrick 00:14, 20 June 2007 (UTC)[reply]