MediaWiki Page Title Variable
I am developing a skin for MediaWiki (version 1.15). I need to include the title of the page being called in the skin. My question is, how do I get the title pragmatically using php? I tried to look into the MediaWiki documentation, but I couldn't find anything for the version of MediaWiki I'm working on.
source to share
The standard way to get the current page title is to get the RequestContext or any IContextSource class, call getTitle()
on it to get the Title object , and then call one of its getter methods, for example getPrefixedText()
.
The Skin class itself is the usual source of context for skins, so in the skin code it looks like this:
$title = $this->getTitle();
echo htmlspecialchars( $title->getPrefixedText() );
(Actually, the Skin class also provides another named method getRelevantTitle()
that you can use instead getTitle()
. The main / only difference is that on certain special pages, such as Special:MovePage
those that operate on a specific wiki page, the "appropriate" title will have the meaning the page to be acted upon, not the special page itself.)
Note that many skins define their own labels for things like the current page title. For example, in Skin Template Vector Code , printing the current page title is done by calling $this->html( 'title' )
. If you are using a new skin in one of these existing skins, you can use the same shortcuts.
source to share