Manual:$wgTitle

From MediaWiki.org

Jump to: navigation, search

[edit] Details

The Title object represents the title of an article, and does all the work of translating among various forms such as plain text, URL, database key, etc. For convenience, and for historical reasons, it also represents a few features of articles that don't involve their text, such as access rights.

The Title object is initialized by the MediaWiki object, $mediaWiki.

Most places in the MediaWiki code have a title already on hand (or a sane one can be easily created). As a general rule, it's better to try and use these when possible and avoid $wgTitle if it's not absolutely needed. The problem with $wgTitle is that it's not a static global like $wgRequest that always refers to the same object--instead, $wgTitle can refer to any title at a given point, since you can't anticipate what an extension might have done with it. A good example is in SpecialPages, where you can easily call the getTitle() method, which returns a localized version of the special page's title, rather than hoping $wgTitle refers to the special page in question.