Is it possible for a MediaWiki extension to detect that it was transcluded? For example, if you have this:
1. Article A transcludes {{T}} 2. Template:T contains a tag extension <MyExtension/> 3. You hit article A.
Can MyExtension.php somehow detect that it was transcluded from Template:T and was not directly part of article A?
I read Title.php and Article.php but didn't see any functions to do this.
Thank you very much, DanB
TemplateInfo[1] did this.
The way TemplateInfo works is that there's a parser hook that can be used in the template namespace. When you transclude the template, the parser hook returns an empty string. When you render the template page the parser hook renders a table describing the data inside the parser hook's content. There was also an API for getting only the parser hook's content for a given template.
Take a look at where[2] we check to see if the frame title is the same as the parsed page's title. If you aren't using a parser hook, this approach won't work, but this hopefully will give you some ideas for how to get something working.
- Trevor
[1] http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/TemplateInfo/ [2] http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/TemplateInfo/Temp...
On Wed, Jul 25, 2012 at 11:21 AM, Daniel Barrett danb@vistaprint.comwrote:
Is it possible for a MediaWiki extension to detect that it was transcluded? For example, if you have this:
Article A transcludes {{T}}
Template:T contains a tag extension <MyExtension/>
You hit article A.
Can MyExtension.php somehow detect that it was transcluded from Template:T and was not directly part of article A?
I read Title.php and Article.php but didn't see any functions to do this.
Thank you very much, DanB
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org