Topic on Project:Support desk

Best way to grab parent categorization of article categories?

3
Subfader (talkcontribs)

Let's say you have a movie wiki and movie articles are categorized like that:

  • [[Category:Action]] >> is in [[Category:Genres]]
  • [[Category:Comedy]] >> is in [[Category:Genres]]
  • [[Category:Bruce Willis]] >> is in [[Category:Actors]]
  • [[Category:Will Smith]] >> is in [[Category:Actors]]

On that movie page I want to be able to use the categories for the json API. But by depending on their parent category type:

  • Get the genre categories of the article and do stuff with them.
  • Get the actor categories of the article and do stuff with them.

I want to output these in the Javascript vars in the DOM like this (preferably in the order as they're added on the article)

  • "wgCategoryTypeGroupGenres":["Action","Comedy"]
  • "wgCategoryTypeGroupActors":["Bruce Willis","Will Smith"]

The parent category names are static and can be defined.

How the hell would I do that? I already have some code to grab the regular page categorization (regex on the article text before output > keeps the category order), but without checking the parent category of each.

It wouldn't make much sense to memcache the query on each page call I guess. Only if a further procedere is added on when a category page is edited.

MarkAHershberger (talkcontribs)
Subfader (talkcontribs)

Thanks, but it looks like SMW is only adding output to pages using SMW syntax.

Reply to "Best way to grab parent categorization of article categories?"