Topic on Project:Support desk

How to check from a template if a page is in a given category?

5
Vanished user e175adb86e72bb96a1706f7ab31b9df8 (talkcontribs)

Hi, I'd like to write a template for Wikisource with a code that would check if a book (page "Index:Book") is in the "Category:Finished" (fictional category name), and then change an icon accordingly. Is there a magic word for that? Or any other way to do it?

Bawolff (talkcontribs)

Not really no (possible to write extension to do that, but no such extension is installed on Wikimedia Wikis at the moment). I suppose DynamicPageList does something kind of close, and might one day be able to do that, but as it stands, cannot.

You could maybe put a book's status in a subpage, (Aka Index:Book/status is a page containing just Finished or whatever ) and then use templates to get the value of that and do stuff based on that (possibly including detemining Index:Book's category based on the content of the subpage).

Vanished user e175adb86e72bb96a1706f7ab31b9df8 (talkcontribs)

Thanks for the advice, Bawolff. I found this template on the italian wikisource that does what I wanted. However I'll have to read the code a couple of times because I still don't fully understand the procedure it uses.

Subfader (talkcontribs)
Bawolff (talkcontribs)

Not yet, but that would probably make a good feature for that extension.

(Basically PageInCat can only detect if the current page is in a category. It can't detect if an arbitrary page is in some category)

However, even if PageInCat did support Micru's request, the extension is not installed on Wikimedia, so can't be used on wikisource.

Reply to "How to check from a template if a page is in a given category?"