On Mon, 06 May 2013 11:59:49 -0700, Jim Hu <jimhu(a)tamu.edu> wrote:
I'm rewriting some of our tag extensions to be
more up to date in coding
practice. In the docs for $wgTitle, it suggests using
$parser->getTitle() to replace $wgTitle in tag extensions. What's the
difference between that and using $frame->getTitle()?
I'm trying to understand what I should be using $frame for.
Thanks!
There are multiple levels of frame. $frame->getTitle() can potentially
refer to say the title of a template being transcluded.
While $parser->getTitle() refers to the title of the actual page being
parsed.
For example if we have:
## [[Template:Foo]]
{{#test:...}}
## [[Bar]]
{{Foo}}
And you parse [[Bar]]. Then $parser->getTitle() should always refer to
[[Bar]]. While for the #test implementation $frame->getTitle() should iirc
refer to the #test parser function somehow (don't remember the specifics)
and $frame->parent->getTitle() should refer to [[Template:Foo]]. And
$frame->parent->parent->getTitle() finally being [[Bar]].
((Ok there are some situations like i18n messages where
$parser->getTitle() may not be the actual page being parsed but the page
it's being parsed to be displayed on))
--
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [
http://danielfriesen.name/]