Manual talk:Special pages

Outdated?
I think this page has to be updated? It seems that you only need a file in the extension directory to create special page now.

An example is the Board Vote file


 * I have accordingly updated the word of warning section. I think the old material is for 1.4, so it's still relevant, so I'm going to try to rewrite the whole thing for 1.5. Ambush Commander 00:09, 22 December 2005 (UTC)


 * As of 1.6.x, my PageCreateOrder extension broke and I spent some time trying to figure out why until I looked at the BoardVote extension you mentioned. I now see that the class I was defining needs to be done inside the loader function and the includes file no longer needs to be there.  I've updated the documentation to reflect this. -- Suso 13:44, 5 May 2006 (UTC)


 * Hey, Suso, are you User:216.9.137.122? (because that's the only edit I see) Ambush Commander 21:30, 5 May 2006 (UTC)


 * Yes I am. Sorry, I must have logged out or something when I made the edit. It happens. -- Suso 22:29, 30 May 2006 (UTC)

create a new special page
Hello, I would like to insert forms in pages related to my wiki, which is necessary to modify in the quick template to have a special page?

a: I didn't have to change anything in the template. Try using BoardVote.php as a model for your page, put it in the extensions directory. You can put your forms in the 'execute' function as this is what gets called automatically when the special page is loaded. To get mediawiki to recognize the existence of your new page, just include it at the end of LocalSettings.php.


 * You probably want to read into Extending wiki markup, which lets you add arbitrary HTML to a page and is great for creating really quick extensions for creating forms. Ambush Commander 00:09, 22 December 2005 (UTC)

clear title &lt; &gt;
I can't remove the &lt; &gt; witch appears on both sides of the page title. First, I added a line in the $wgValidSpecialPagesFr array and then in all arrays of my language file. I read the explanation with the addMessage function but y didn't very understand because of my bad english. Barbux 22:10, 1 October 2005 (UTC)
 * Put  into the start of your wfExampleExtension after the globals declaration.
 * Failing that, create this page: MediaWiki:Yourpagename and put the name of your page there. Ambush Commander 00:09, 22 December 2005 (UTC)
 * Had same problem. Solution was to make sure that keys in i18n file were lower-case. Happy Joe 13:59, 30 December 2008 (UTC)

Had same problem, brute-forced by adding $wgOut->setPageTitle(wfMsg('myextension')); in execute function under wfLoadExtensionMessages... --76.8.128.114 18:59, 18 November 2009 (UTC)

sysops only?
ImaTard 20:06, 31 October 2005 (UTC)

How would i go about making a sysops only special page? im using v1.5

a:I thought it might help to show what I have in my code at the beginning of my execute function: if (! $wgUser->isBureaucrat && ! $wgUser->isDeveloper ){ $wgOut->errorpage( "bureaucrattitle", "bureaucrattext" ); return; } This code only allows admins to use the page. Note that i have only tested this on v1.4.6 though.


 * This is a good idea for a section on the page, but it's fairly obvious if you just look at some of the code. Those functions are deprecated, you can use: . Ambush Commander 00:12, 22 December 2005 (UTC)


 * Extra note: the code given earlier does not make the page sysops only. Ambush Commander 00:13, 22 December 2005 (UTC)

I'm using 1.8, and i'm having problems as well...Here's what i have in my function: SpecialPage::addPage(new SpecialPage('ArchiveNews', 'sysop', true, 'ArchiveNews', false)); I thought that passing "sysop" as the second parameter would only allow sysops to see the page. But, when i do that and go to the page, I get: Permission error You are not allowed to execute the action you have requested. I am a sysop, so i can't figure out why it wouldn't work...is this by chance deprecated? I've tried everything...sysop, admin, administrator, etc, and nothing works. The only thing that made any difference, was when i set it to "bot" just for fun, and I got a different message, stating that I was not in the group "bots". Any help would be appreciated. --Duke33 22:31, 20 December 2006 (UTC)


 * The second parameter of 's constructor is the right needed to view the page, not the group. Since (by default at least) a bureaucrat's only right is userrights, pass   as the second parameter to limit the page to bureaucrats. To limit the page to sysops, consider why -- because sysops can   pages? Or   files? A full list of default user group/rights settings is in  . 23:18, 22 May 2007 (UTC)

Modification needed for 1.6
I just made a special page using the example found on this page. But, apparently on 1.6 you need to add this to the execute; function.

$wgOut->setPagetitle( wfMsg( 'messagename' ) ); -- Phroziac (talk) 20:34, 8 November 2005 (UTC)


 * This is not necessary. Read about how MediaWiki can be used to dynamically load extensions and their functions. Ambush Commander 00:09, 22 December 2005 (UTC)

Revert to previous version
In this edit User:Slanted reverted the new set of instructions to a pre-1.5 state. The edit was marked minor and had no edit summary, so I chose to revert him before posting an inquiry on his talk page. So... discussion? Ambush Commander 02:52, 5 January 2006 (UTC)

Add setHeaders to example?
The code in SpecialPage.php says you should call setHeaders in your execute function. This turns out to be necessary to set the window title and other stuff (Thanks to Michael on Wikitech-l for pointing this out). Shouldn't we add something like the following to the example on this page? $this->setHeaders; // call this method of the super class to set the window title

--Jmcneil86043 19:09, 7 January 2006 (UTC)


 * SpecialPage automatically calls the function from its base method. Notice how in the code examples, I do not inherit a new class from SpecialPage. Calling this is only necessary if you overload execute and you don't call the original. Generally, inherited classes are overkill: UnlistedSpecialPage and IncludableSpecialPage should have all the alternate functionality you need, and there probably should not be any domain logic inside the SpecialPage class (perhaps somewhat counterintuitively).


 * However, if you followed the instructions correctly, it should have worked. Where did you get your special page template anyway? Ambush Commander 00:01, 8 January 2006 (UTC)

I based my code on BoardVote.php, which was recommended in the old code as an example (I started this code a few months ago when that doc was current). It was over-complicated for my purposes, but I am implementing a form, so it was helpful. These new docs are more simple, but It's not completely obvious how to do a form, although I guess I could figure it out with a little work. Do you recommend calling the base-class' execute method, or re-writing so I don't sub-class? I'm going to be doing several more of these, so I'd like to do this prototype correctly. Thanks, --Jmcneil86043 03:58, 8 January 2006 (UTC)


 * The developers likely aren't in agreement about everything. After all, I am just an outside. My observations are based off the upload special page, which Vibber does say is a, and I paraphrase, piece of crap. I'll do some more research on the other standard special pages. I think that this simply way is a lot better though.


 * Regarding your question about rewriting versus calling the base class's execute method, you can't call the base class's execute method because it will go off and call the function anyway (even if it doesn't exist). You will have to rewrite it, or give it a dud function. Not that you'd want to: just put all the logic inside the function that it calls. Do you understand that idea?


 * Regarding the creation of forms, I do need to add some documentation about . I'm concerned, however, that the page is getting a bit long. Ambush Commander 00:36, 9 January 2006 (UTC)

Passing Parameters to a Special Page?
Is there any way to pass parameters to a special page? &mdash;The preceding unsigned comment was added by Behrang Amini (talk &bull; contribs).


 * Yes, see "Special Parameters" on article page
 * 84.137.220.251 14:12, 2 March 2006 (UTC)

How about calling SpecialPage::executePath in the php code. How can I pass parameters to the page? Nazly.elshazly 09:35, 17 January 2007 (UTC)

Special:Example
Special:Example is dead. &mdash;The preceding unsigned comment was added by 80.185.25.241 (talk &bull; contribs).
 * Of course. There's no special page by the name of Example on this wiki. Ambush Commander 21:46, 18 January 2006 (UTC)

Special Characters in $wgMessageCache->addMessages
Hi, how is it possible to put german umlauts in $wgMessageCache->addMessages? (&amp;ouml; or &amp;#246; don't work) 84.137.220.251 14:10, 2 March 2006 (UTC)


 * I suppose MediaWiki expects pure text. I recommend using . Remember, you can always edit the corresponding system message if you don't want to put special characters in the source code. Ambush Commander 22:38, 3 March 2006 (UTC)


 * > Remember, you can always edit the corresponding system message if you don't want to put special characters in the source code.
 * That's a splendid Idea. I'm going to do it like that, thanks! By the way, I tried " " and it didn'd work either (allways get a question mark instead of the special character).
 * Otterstedt 21:22, 4 March 2006 (UTC)


 * Hmm... that's interesting. Probably 246 is the incorrect number (it's in decimal, not hex, and remember, it has to be UTF-8 encoded). I'll have to look into that (or a developer, in their infinite wisdom, will give us the answer). Glad you resolved your problem though. Ambush Commander 23:20, 4 March 2006 (UTC)


 * I'm getting a little bit annoyed with not finding information on how to actually achieve this. I'm writing an extension with finnish texts. Nothing so far has been displayed correctly. Including the above tip. And the tip about being able to edit the messages Special:Allmessages page doesn't work either for some reason. In my extensions/SpecialDigitemp.php I have this
 * The message name and the message itself are present in the Special:Allmessages page, but when trying to edit the message I get a page saying that the page doesn't exist. The link on the Special:Allmessages page for the word digitemp is
 * http://xxx/wiki/index.php?title=MediaWiki:Digitemp&action=edit when for other texts it's
 * http://xxx/wiki/index.php/MediaWiki:Diff
 * So what's the deal? And how to get ä's and ö's to work? &mdash;The preceding unsigned comment was added by 193.167.88.25 (talk &bull; contribs).
 * You need to use the  (HTML Unicode format) encoding when hard coding messages. Nn is equivalent to the decimal number representing the character. For example:
 * When using messageCache you could use php's utf8_encode function to convert your strings to UTF-8 like in the following:
 * Hope this helps. &mdash;The preceding unsigned comment was added by 213.186.252.201 (talk &bull; contribs).
 * When using messageCache you could use php's utf8_encode function to convert your strings to UTF-8 like in the following:
 * Hope this helps. &mdash;The preceding unsigned comment was added by 213.186.252.201 (talk &bull; contribs).
 * Hope this helps. &mdash;The preceding unsigned comment was added by 213.186.252.201 (talk &bull; contribs).

The system messages aren't supposed to exist. Here's the thing: as an aide to you, the MediaWiki installer automatically populates the core set of system messages. Most extensions don't do so. Just create the page and it will work as normal. I strongly discourage non-ASCII characters in source code, just because of encoding issues (if you're using the wrong encoding, they'll show up weird in the source (unlikely, since Latin-1 is the most widely used character set (but still possible, esp. for non-European languages))). Ambush Commander 23:09, 31 March 2006 (UTC)

Modifying permissions for existing special pages
An anon posted this. I don't agree with it's methodology, but the main reason it's not appropriate for this article is that it has nothing to do with new special pages. Just old ones. Anyone know of a more appropriate place to put it? Ambush Commander 04:18, 30 March 2006 (UTC)

This was my post. I postet it because I was looking for that kind of solution for preventing access for some hours in the documentation in here before I used my own brain ;-) But you are totally right, it is not about writing a new page. So I fitted it now in there, where I would have expected it at first and where it is fully logical: at Preventing_Access.


 * Great job. (removed text) :-D Ambush Commander 21:31, 30 March 2006 (UTC)

Defining functions/classes from a function
I don't think that defining classes/functions from inside a function is conceptually the cleanest way to go about doing things. In fact, the developers tend to disagree about where the extension code should go.

From this page:, here's an overview of what developers are doing:


 * Cite by avar - inlined inside function, extends special page class
 * Makebot by robchurch - non-conditional definition, extends special page class
 * NewestPages by robchurch - non-conditional definition, extends special page class
 * SpecialMakesysop by timstarling et al - non-conditional definition, uses generic special page class but tells special page not to load file
 * SpecialRenameuser by avar - inlined inside function, extends special page class
 * SpecialCrossNamespaceLinks by avar - inlined inside function, extends special page class
 * BoardVote by vibber - inlined inside function, extends special page class
 * SpecialFileList by Magnus Manske - inlined inside function, extends special page class
 * PurgeCache by robchurch - unconditional definition, extends special page class
 * SpecialFilePath by avar - inlined inside function, extends special page class
 * LuceneSearch by vibber - inlined inside function, extends special page class
 * OAI repository by vibber - inlined inside function, extends special page class
 * SiteMatrix by vibber - inlined inside function, extends special page class

Ambush Commander 22:23, 5 May 2006 (UTC)

Egads! It seems I was barking up the wrong tree to begin with! Ambush Commander 04:27, 7 May 2006 (UTC)

BoardVote example -- where is it?
The article says:
 * If this is unclear, you might check out the BoardVote.php file in the extentions/BoardVote directory, as it does things the right way.

Great, but BoardVote.php is not in my extentions/BoardVote directory. If this is supposed to be the canonical example, how about publishing it where folks can see it -- like the extensions category here? JohanTheGhost 15:05, 20 May 2006 (UTC)


 * I used to not endorse that statement, but it prompted me to check out a bunch of the other extensions by leading developers, and it turns out that inlining the class definition in the function is the commonly accepted way. Please see the above topic, Defining functions/classes from a function.


 * You can view the HEAD version of the BoardVote extension in the SVN repository. Personally, I wouldn't use it as a template since it's a bit too complicatd. &mdash; Ambush Commander (Talk) 17:27, 20 May 2006 (UTC)

Question...
Ok can some one explain to me why when I follow the instructions on this page I end up with a blank Special Pages page?


 * I'm using Fedora Core 5
 * MediaWiki: 1.9.3
 * PHP: 5.1.6 (apache2handler)
 * MySQL: 5.0.27

April 17 2007


 * add the following line in MyExtension_body.php

# Do stuff $output = 'Hello World!'; Vic 21:51, 23 April 2007 (UTC)
 * Vic add this to MyExtension_body.php right after your <?PHP line:

error_reporting(1); This should give you the error instead of a blank page 00:52, 25 April 2007 (UTC)

Special Page with MW Version 1.6.9
Hi, I've written a special page with the proposed template and it works really fine with 1.9.3. But under V 1.6.9 I can't call that page (It is listed under Special:Version, but not at Special pages and if I call it directl it doesn't exist) :-(  I googled a little bit and found that this problem exists. Do you know how to solve it?

Thanx Chris

Other Important Files?
I really didn't get where I'm supposed to stick this stuff. Lets say I want to make it so that my special page does not appear in Special:Specialpages, what function exactly am I supposed to modify in the above code? Can anyone clarify please? --Nate 89.0.127.224 23:58, 1 October 2007 (UTC)

Making a Special Page Printable
How do I go about this? I have a special page that I created that needs to be printable. If I pass in a variable to tell the Page it should be printable is there a function that should be called in the code for that page to let the parser know to make it printable instead of using the standard display?

Thanks Will
 * I believe that just by printing the page, the browser will automatically figure out (using the  calls in the CSS) the correct way to display it for printing. 68.80.149.10 16:36, 31 October 2007 (UTC)

Cache Question
Regarding caching, I was wondering how to go about doing an object cache. I assume MediaWiki abstracts the underlying cache systems (memcahed, APC, DB cache, etc), and was just wondering what class I would need to call to do some basic object caching. I can figure it out from there with the help of the code documentation, just need to be pointed at the right class ;)

Thanks, 68.80.149.10 16:34, 31 October 2007 (UTC)

Special:Statistics
My Special:Statistics page has a huge number (18,446,744,073,709,551,614) listed in "Excluding those, there are $2 pages that are probably legitimate content pages.". Any idea why this is? --Egingell 03:05, 8 January 2008 (UTC)

Problem with SpecialPage hooks
As per https://bugzilla.wikimedia.org/show_bug.cgi?id=10719, extensions that subclass SpecialPage and implement their own execute function have a couple of drawbacks. The main one being they don't fire off all the SpecialPage hooks that SpecialPage::execute fires. Also, the subclass execute function has to call setHeaders and do it's own user permission checking. I added some information on all this and suggested a work around here: Manual:Special pages. --Cneubauer 22:36, 11 February 2008 (UTC)

php4
This manual includes a note saying: It should be pointed out that the method used below will not work on PHP 4:. Where can I find the description on how to write a Special page-extension with Mediawiki 1.6 and PHP 4? -- JanCK 11:43, 11 April 2008 (UTC)


 * Try an old revision of the page.  should probably work.  --Cneubauer 12:12, 11 April 2008 (UTC)

landing page
I cannot find anything in the manual to create a landing page like wikipedia.org have. Can someone tell me how I can make a landing page like wikipedia's, but the only 2 differences will be that I will have a different Image and it will be a size of 800x600 pixels(i want to be able to write some text underneath the image too). I want the search box removed and replaced with a enter button and a leave button. the enter button will take people to the Main_Page and the leave button will take people to another url. I am not a professional programmer so could you explain it to me step by step. for example, open up main.php and put the code main=45435HTMLetcetc underneath the existing code on line 45 underneath 4534534head.php, then create a new file and upload it in the home directory etc etc.Ryan1414 01:37, 3 July 2008 (UTC)

looking for developer to modify wiki
i am looking for a developer who can code new functions into wiki. please have a look at http://www.wikinvest.com/stock/Apple_(AAPL) i want to add functions like bulls, bears and chart function to wiki. i am ready to pay for the final product.

Error message: Parse error: syntax error, unexpected $end, expecting T_FUNCTION in
Hi, I am trying to write an specialpage, now i am getting this error message if i try to run the special page: "Parse error: syntax error, unexpected $end, expecting T_FUNCTION in" The error is located in the end of my body.php file.

Someone knowing this error?

Thanks Niels


 * Hate that PHP error - basically means you forgot to close a brace (one of these { ) somewhere in your document. Go back, check your functions, and make sure you closed each one properly. 206.231.255.81 21:10, 6 May 2009 (UTC)

Problem with the setup instructions under 1.13.3
I had these problems when I followed the setup instructions to the letter with 1.13.3:


 * $wgExtensionCredits version should be a number, not a string (I've fixed the page for this)
 * if I include descriptionmsg it fails for some reason (despite being defined in the i18n file)
 * if I include the $wgExtensionAliasesFiles line it fails
 * if I include $this->setHeaders in execute it fails

for all cases it fails in the most frustrating way - no log messages of any sort, if I click on (eg) Special Pages it just ignores it and stays on the current page.

Download further down?
At the " Basic special page template" section, "A working copy is available for download, see further down"
 * Where?


 * Manual:Special_pages - link at the bottom of that section. 142.164.181.107 20:08, 23 June 2009 (UTC)

setup special page
I'm trying to create a new special page on my wiki, and I must be missing something - I don't see any information here about how to access the page. I have created the four files, and put them in extensions/MyExtension. I've tried going to /Special:MyExtension and /Extension:MyExtension - the first errors, and the second is empty. Do I have to register the new page in another file somewhere? The instructions could be much clearer. 24.28.83.55 05:23, 24 July 2009 (UTC)


 * In case someone has the same problem: yes, you do need to "register" the page in another file somewhere, in LocalSettings.php, like any other 'extension'. This was mentioned obliquely on the page, as the error output of one of the php scripts. I personally copied and pasted all the php code without reading it - I wanted to get the page working before delving into the details. I might have been less hasty, but in any case I have edited the page to be a little more clear.


 * This requirement may be obvious to some more experienced mediawiki users - its obvious to me in retrospect. I had this problem because I was attempting to create a "Special Page" and not an "Extension" - I did not realize that "custom Special Page" is exactly the same thing as an "Extension" - for all I knew, the software scans files in the extensions directory looking for references to the SpecialPage class. 146.6.204.46 20:28, 24 July 2009 (UTC)

Wann endlich in Deutsch?
Es wäre ungeheuer notwendig, wenn es diese Erläuterungen endlich auch in deutscher Sprache gäbe. So gut kann das amerikanische Englisch der Durchschnittsdeutschen nicht sein, um hier keine Fehler zu begehen.--Jens Rusch 06:49, 25 September 2009 (UTC)


 * Doch, kann es ;) Ausserdemski muss man dafür nur Code-English können, kein AE. 78.52.97.34 18:49, 26 October 2009 (UTC)


 * Eine deutsche Übersetzung wäre dennoch wünschenswert. Ich stolper jedesmal in irgendwelche Fallen. Bei Zeit und muse setz ich mich mal ran. --213.214.18.64 12:11, 14 January 2010 (UTC)

Make special page transcludable
I can guess from the documentation availabre that there is a way of making ones SpecialPage transcludable (meaning it can be included in other pages like this: . However I couln't make it work for my special page. When I add the code to an article it only generates a link to the special page. No transclusion. Any ideas?