1

I was wondering if there was a way, to show certain parts of my footer, only when in certain categories.

E.g. a email link (mailto) only when in the Category:FAQ

I am using a custom Skin.

Divide by Zero
  • 1,343
  • 1
  • 14
  • 37

2 Answers2

1

With help of this snippet a CSS class is added to your body tag for every category the current page belongs to. You could then display or hide certain elements with help of the corresponding class.

0

If you are using your own, custom skin, you can just check what categories your current wikipage belongs to, by calling OutputPage::getCategories(). This will probably affect caching, though.

if (in_array( 'FAQ', $out->getCategories() ) {
  // do something
}

edit: @Florian points out below, that you should use OutputPage methods to output stuff, rather than echoing them, so I removed that unfortunate example. And as @Florian also points out, if you want this effect to persist also for users who might have selected another skin than your custom one, you'll have to use a hook, e.g.SkinTemplateOutputPageBeforeExec.

leo
  • 8,106
  • 7
  • 48
  • 80
  • You can do this with hooks, too, which are also called in the near of the footer and provide access to an OutputPage object, too. Also I would recommend to use OutputPage to add content to the output, rather then using echo or print. – Florian Feb 02 '16 at 13:41
  • 1
    Thank you for this answer @leo & florian . How exactly would i use the hook? And where does it go? Into my customSkin.php ? Best regards. – Divide by Zero Apr 13 '16 at 09:31
  • 1
    You would create an extension (or, if the code is really small, you could even call the hook in LocalSettings.php). Have a look at https://www.mediawiki.org/wiki/Manual:Developing_extensions – leo Apr 13 '16 at 10:54