Hi, I am creating a tag extension that uses the categories of the current page. How can I get a list of all categories that are assigned on the page?
And I don't want the parent categories. I have found $wgPageTitle = $parser->getTitle(); $wgParentCats = $wgPageTitle->getParentCategories(); but it lists all the parent categories as well.
Thanks, Andi
Could you get the page text and parse out the category line? Might not be the most elegant solution though. -Courtney
-----Original Message----- From: wikitech-l-bounces@lists.wikimedia.org [mailto:wikitech-l-bounces@lists.wikimedia.org] On Behalf Of Andreas Rindler Sent: Wednesday, September 05, 2007 7:13 AM To: MediaWiki announcements and site admin list; wikitech-l@lists.wikimedia.org Subject: [Wikitech-l] Categories of current page
Hi, I am creating a tag extension that uses the categories of the current page. How can I get a list of all categories that are assigned on the page?
And I don't want the parent categories. I have found $wgPageTitle = $parser->getTitle(); $wgParentCats = $wgPageTitle->getParentCategories(); but it lists all the parent categories as well.
Thanks, Andi _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
On 05/09/07, Andreas Rindler mediawiki@jenandi.com wrote:
Hi, I am creating a tag extension that uses the categories of the current page. How can I get a list of all categories that are assigned on the page?
And I don't want the parent categories. I have found $wgPageTitle = $parser->getTitle(); $wgParentCats = $wgPageTitle->getParentCategories(); but it lists all the parent categories as well.
That should work, if I'm reading the code right. What do you mean by "the parent categories"? It's listing the parents of the categories the article is in? It should be listing just the parents of the article, ie. which categories it is in, unless I'm seriously misunderstanding the method.
My bad, it is working. I was using templates and the template itself had categories assigned. So between the original categories and the ones coming through the template I got all confused.
Sorry, Andi
On 05/09/07, Thomas Dalton thomas.dalton@gmail.com wrote:
On 05/09/07, Andreas Rindler mediawiki@jenandi.com wrote:
Hi, I am creating a tag extension that uses the categories of the current page. How can I get a list of all categories that are assigned on the page?
And I don't want the parent categories. I have found $wgPageTitle = $parser->getTitle(); $wgParentCats = $wgPageTitle->getParentCategories(); but it lists all the parent categories as well.
That should work, if I'm reading the code right. What do you mean by "the parent categories"? It's listing the parents of the categories the article is in? It should be listing just the parents of the article, ie. which categories it is in, unless I'm seriously misunderstanding the method.
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Andreas Rindler wrote:
Hi, I am creating a tag extension that uses the categories of the current page. How can I get a list of all categories that are assigned on the page?
And I don't want the parent categories. I have found $wgPageTitle = $parser->getTitle(); $wgParentCats = $wgPageTitle->getParentCategories(); but it lists all the parent categories as well.
Thanks, Andi
I'd say that what you want is exactly getParentCategories() "Get categories to which this Title belongs and return an array of categories' names."
mediawiki-l@lists.wikimedia.org