Template talk:Category

From MediaWiki.org
Jump to: navigation, search

Contents

[edit] Page existence approach

Use {{#ifexist: ...}}, so it can also be used in english pages, which has no subpage part, but this will then put the non-english pages into english category pages, and discourage the creating of non-english category pages.

[[Category:{{{1}}}{{#ifexist: Category:{{{1}}}/{{SUBPAGENAME}}|/{{SUBPAGENAME}}}}|{{BASEPAGENAME}}]]

When using {{Category|Help}} in the following pages,

  • Help:Deleting a page/th
    • [[Category:Help/th|Deleting a page]]
  • Help:Deleting a page
    • [[Category:Help{{#ifexist: Category:Help/Deleting a page|/Deleting a page}}|Deleting a page]]
      • [[Category:Help|Deleting a page]]
  • Help:Deleting a page/xx (where xx is some valid language code, and the page Category:Help/xx doesn't exist yet)
    • [[Category:Help|Deleting a page]] (discourage the creating of Category:Help/xx page)


[edit] PAGENAME and SUBPAGENAME equality approach

An alternative approach may be to check for the equality of the PAGENAME and SUBPAGENAME to see if the page has subpage part or not. This will put the non-english pages into the category of their corresponding language, even that that category page doesn't exist.

[[Category:{{{1}}}{{#ifeq: {{PAGENAME}}|{{SUBPAGENAME}}||/{{SUBPAGENAME}}}}|{{BASEPAGENAME}}]]

But this approach can't be used in the english page that has subpage parts, that is not the language code, like "Title1/subpage1", rather than, "Title1/subpage1/en". --Ans 15:08, 4 February 2008 (UTC)

When using {{Category|Help}} in the following pages,

  • Help:Deleting a page/th
    • [[Category:Help{{#ifeq: Deleting a page/th|th | | /th }}|Deleting a page]]
      • [[Category:Help/th|Deleting a page]]
  • Help:Deleting a page
    • [[Category:Help{{#ifeq: Deleting a page|Deleting a page | | /Deleting a page }}|Deleting a page]]
      • [[Category:Help|Deleting a page]]
  • Help:Deleting a page/xx
    • [[Category:Help{{#ifeq: Deleting a page/xx|xx | | /xx }}|Deleting a page]]
      • [[Category:Help/xx|Deleting a page]] (new Category page with red link, encouraging creating of that new Category page)
  • Help:Deleting a page/Subpage
    • [[Category:Help{{#ifeq: Deleting a page/Subpage|Subpage | | /Subpage }}|Deleting a page]]
      • [[Category:Help/Subpage|Deleting a page]] (unexpected category page)

[edit] Language code validity approach

The most appropriate approach will then be to check if the subpage parts is language code or not, by the aid of {{#language:..}} magic. --Ans 15:10, 4 February 2008 (UTC)

This is done by check the equality of {{#language:code}} and "code". --Ans 15:18, 4 February 2008 (UTC)
{{#ifeq: {{#language:{{SUBPAGENAME}}}}|{{SUBPAGENAME}} |
[[Category:{{{1}}}|{{PAGENAME}}]]|
[[Category:{{{1}}}/{{SUBPAGENAME}}|{{BASEPAGENAME}}]]}}

When using {{Category|Help}} in the following pages,

  • Help:Deleting a page/th
    • {{#ifeq: {{#language:th}}|th | ... }}
      • {{#ifeq: ไทย|th | ... }}
        • [[Category:Help/th|Deleting a page]]
  • Help:Deleting a page
    • {{#ifeq: {{#language:Deleting a page}}|Deleting a page | ... }}
      • {{#ifeq: Deleting a page|Deleting a page | ... }}
        • [[Category:Help|Deleting a page]]
  • Help:Deleting a page/xx
    • {{#ifeq: {{#language:xx}}|xx | ... }}
      • {{#ifeq: xx native language name|xx | ... }}
        • [[Category:Help/xx|Deleting a page]]
  • Help:Deleting a page/Subpage
    • {{#ifeq: {{#language:Subpage}}|Subpage | ... }}
      • {{#ifeq: Subpage|Subpage | ... }}
        • [[Category:Help|Deleting a page/Subpage]]

[edit] Purpose

Can someone please explain the point of this template before it gets used all over the site? If it is just to automatically figure out which language of category to include a page in then I think this is better served by a bot. --HappyDog 13:32, 18 February 2008 (UTC)

Is it better to do it automatically (internally) without needing external bot? --Ans 15:05, 5 June 2008 (UTC)
It also help, when adding new language subpage, just copy the content from english page, without needing to modify the category of new language page --Ans 15:17, 5 June 2008 (UTC)
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Toolbox