Board Thread:Support Requests - Getting Technical/@comment-31246436-20161104134036/@comment-24473195-20161104172541

Saftzie wrote: If you want to query for a specific, known category, you can use the Scribunto library function  to get a list of pages in the category, then check to see if the current page is in the list returned.

Lua could also retrieve the contents of the page and try to parse it for things that look like, but that would be unreliable. For example, this post contains that string, but it's enclosed in, so it's not in the category. Alternatively, categories could be added by templates, so they'd be missed.

JavaScript would be cleaner, since there's an API for that (action=query & prop=categories). Depending how you intend to use category membership, js may or may not meet your needs. Pagesincategory doesn't do what you think it does. All it does is return a table with statistics related to a page, e.g. total number of subcategories (https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#mw.site.stats.pagesInCategory).

It is currently impossible to verify if a particular page uses a category or to get a list of pages in a category using only lua short of parsing the whole page and each template. As you note this won't retrieve the categories within a template. Any such solution would also be quite fragile and problematic using lua or templates, for example, if you try to obtain a list of categories in the current page, and then another template  or even the same one adds yet another one. It would result in "category inception".

The only alternatives are mw:Extension:DPL or Javascript. DPL has the same problem as lua or simple templates.