Reputation: 69
I am designing a skin for a MediaWiki(Version 1.15). I need to include the title of the page being called into the the skin. My question is, how to obtain the title pragmatically using php? I tried looking into the documentation of MediaWiki but I could not find anything for the version of MediaWiki I am working on.
Upvotes: 3
Views: 260
Reputation: 50328
The standard way to get the current page title is to obtain a RequestContext or any IContextSource class, call getTitle()
on it to get a Title object, and then call one of its getter methods, such as getPrefixedText()
.
The Skin class itself is the normal context source for skins, so in skin code, this would look something like:
$title = $this->getTitle();
echo htmlspecialchars( $title->getPrefixedText() );
(In fact, the Skin class also provides another method named getRelevantTitle()
which you may want to use instead of getTitle()
. The main/only difference is that, on certain special pages like Special:MovePage
that act on a particular wiki page, the "relevant" title will be that of the page being acted on, rather than of the special page itself.)
Note that many skins define their own shortcuts for things like the current page title. For example, in the Vector skin template code, printing the current page title is done by calling $this->html( 'title' )
. If you're basing your new skin on one of these existing skins, you may prefer to use the same shortcuts.
Upvotes: 1