I'm using a template {{MyTemplate|foo}}
which consists of the following code:
{{#switch: {{{1}}}
| foo = [[Category:Foo]]
| bar = [[Category:Bar]]
| #default = [[Category:Unknown]]
}}
When I'm using it on a page, the categories show up nicely as wished at the bottom of that page. But unfortunately inside of that category-page (Category:Foo for example) the page doesn't show up.
If I add [[Category:Foo]]
manually to that page, the page shows up in the Foo-category-page.
Any suggestions why this doesn't work via the template?
Does the template page that contain the previous code appear under Unknown
category?. If yes, then any page contain that template must appear in it's category. You may just have to clear cache, and wait few seconds if you have a large wiki.
Make sure that foo & bar categories are not hidden in your wiki. See this: https://www.mediawiki.org/wiki/Help:Categories#Hidden_categories
EDIT
Also, try one of these solutions, which can do the same goal:
{{#switch: {{{1}}}
| foo = [[Category:Foo]]
| bar = [[Category:Bar]]
| #default = [[Category:Unknown]]
}}
OR
{{#ifeq: {{{1}}} | foo | [[Category:Foo]] | {{#ifeq: {{{1}}} | bar | [[Category:Bar]] | [[Category:Unknown]]}} }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With