1

I currently have a simple infobox template running on an internal mediawiki. I would like to pass the pages category to the template so that i can generate a list using category tree.

Is it possible to have the template pick up Category = foo

from my pages that already have [[Category:Foo]]

written on them?

i.e my template text at the top of the page would have a section like

{{Infobox website | Category = *something* }}

to pick it up from [[Category:Foo]] that I already have on all of my pages?

1 Answer 1

0

There is no built in Magic Word for getting the categories, but you could easily create a parser function for that, and use the output with e.g. the Arrays extension to find out if a page is in a certain category or not. However, this seems like a lot of work to save very little work (typing a few extra letters once in a while).

If you want to create a parser function to get the current it is as simple as this:

function getCategories( &$parser, $title) {
    // Will return a comma separated list of categories.
    $categories = $title->getParentCategories();
    return implode(",", $categories);
}

If you know what categoery to check for for each page, you could also use Extension:PageInCat.

Edit: I see now that your question is tagged Semantic MediaWiki. That makes it simple:

{{#if:
  {{#ask:[[Category:Foo]] {{FULLPAGENAME}}|default=|}}
  |''This page is in Category:Foo!''
  |''This page is not in Category:Foo. Let's add it.''
}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.