6

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?

user2033412
  • 1,950
  • 2
  • 27
  • 47

3 Answers3

4

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]]}} }}
ASammour
  • 865
  • 9
  • 12
  • They did appear under the unknown-category. I fixed that (includeonly-embracing). The categories are not hidden. I cleared the cache of the category-page and the template page, but no change: All pages still appear under the unknown-category. – user2033412 Oct 24 '18 at 08:12
  • You mean when you open Unknown-category page, you find all pages using that template inside of it? – ASammour Nov 03 '18 at 19:34
  • Exactly, they all appear there! – user2033412 Nov 05 '18 at 14:07
  • Now they do not appear in the Unknown-category anymore but they still do not appear in the foo- or bar-category. :-( – user2033412 Nov 06 '18 at 14:11
0

Do you run the jobqueue on your wiki? Linkstables are updated asynchronously and not at page save time.

https://www.mediawiki.org/wiki/Manual:Job_queue

https://www.mediawiki.org/wiki/Manual:RunJobs.php

FO-nTTaX
  • 601
  • 5
  • 11
  • Yes, this runs automatically every two hours and updates the categories that are not added conditionally. However the conditional-categories don't work. – user2033412 Nov 03 '18 at 14:37
0

Cant understand the description to your problem, but anyway, it seems like you could achieve the same goal by:

{{#vardefine: my_category |wow}}
[[Category: {{#ifeq: {{#var:my_category}}| default| unknown| {{#var:my_category}} }} ]]

Which adds this category to the page, In my opinion, you should use switch when you are adding category in any case but also decide not to add category in another case.

If you are adding category in all cases, you can write as i wrote above, or export the final category to another variable and use it inside the category.

As for your problem, you can use "?action=purge" for this page, if that wont work, write here some more info.

Kosho-b
  • 161
  • 5