Template:Main talk other flex

From "PTTLink Wiki"
Revision as of 19:19, 21 January 2022 by Kg7qin (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Template documentationview · edit · history · purge ]


This is the {{main talk other flex}} template.

It helps other templates detect what type of page they are on.

Documentation for all these templates are at {{main talk other}}.

This template works exactly the same as the {{main talk other}} template, but it has some minor internal differences. The documentation at {{main talk other}} covers some of the differences, the rest are explained below.

Note! Do not optimise or cut away any "unnecessary" parts of the code in this template. This code serves as an example to copy and paste from and then modify, when one wants to make other templates that detect more complex namespace combinations. That's why the code contains a full list of the Wikipedia namespaces, even for the "other" case.

About the code

The line "| {{lc:{{ns:0}}}} = " probably needs some explanation. Currently mainspace (article space) doesn't have a name, so for mainspace the magic word {{NAMESPACE}} returns an empty string. Fortunately MediaWiki switch-cases can handle empty strings. So that line could simply be "| = ". But just in case the mainspace ever gets a name we use the "{{ns:0}}" which should give the name of namespace 0, that is mainspace. And since we lower case the input then we also have to lower case the value we compare, thus we add "{{lc:}}". Another reason we use that code is in-case people want to reuse that approach for the other namespaces when they reuse this code elsewhere. It would be especially useful when porting this template to an other language Wikipedia or other Wikimedia project.