Topic on Project:Support desk

Text automatically appearing on pages with a specific category?

3
TorstenBerg (talkcontribs)

Hi,


is it possible to have some specific text/content appear in a custom place of all pages belonging to an individual category? My use case is that we have pages in the category "Archive". We want to show a kind of banner at the top of the these pages only, so it should only appear when the page is in the "Archive" category.


I know about templates that can be used to include a predefined text on any page - but this is not automatic since I would need to manually include the template on any page I put into the "Archive" category. I would like to have the text included automatically as soon as the page is put into the category "Archive".


Is there a way to achieve this?

Bawolff (talkcontribs)

Usually people have the template put the page in the category, so its automatic for anything with the template.


There's probably things you can do with either js or php extensions.

See also extension:PageInCat (maybe combined with mediawiki:sitenotice. Not sure if sitenotice is rendered per page)

TorstenBerg (talkcontribs)

Thanks for the help! So I now did what you suggested: instead of writing the category "Archive" directly into the page using the "Category" mechanism, I just use the template for the archive. The template will then add the category itself and add the info box at the top of the page. Quite handy and easy enough, as it also allows users with access to the template to change the info text!