Template:Main namespace only: Difference between revisions
(Created page with "<includeonly>{{#if:{{NAMESPACE}}||{{{1}}}}}</includeonly><noinclude> This template includes the contents passed to {{c|=1}} only if the final transcluding page is in the Main namespace. This is useful because many categories are only meaningful in the main namespace, but you might still want to use the template itself in other namespaces. It also makes it easier to write page-generating templates without the "demo" parameter that prevents categorization. The template...") |
m (note the transclusion) |
||
(One intermediate revision by the same user not shown) | |||
Line 6: | Line 6: | ||
The template functions by fetching the <code><nowiki>{{NAMESPACE}}</nowiki></code> [https://www.mediawiki.org/wiki/Help:Magic_words#Namespaces magic word]. NAMESPACE is an empty string for the Main namespace, and the name of the namespace otherwise (e.g. File:, Category:...). Simply checking whether NAMESPACE exists is therefore sufficient to detect whether the page is in the main namespace. Additionally, magic words are evaluated in the final page they are transcluded into. | The template functions by fetching the <code><nowiki>{{NAMESPACE}}</nowiki></code> [https://www.mediawiki.org/wiki/Help:Magic_words#Namespaces magic word]. NAMESPACE is an empty string for the Main namespace, and the name of the namespace otherwise (e.g. File:, Category:...). Simply checking whether NAMESPACE exists is therefore sufficient to detect whether the page is in the main namespace. Additionally, magic words are evaluated in the final page they are transcluded into. | ||
For convenience, [[Template:Main only]] points to this template. | |||
<templatedata> | <templatedata> |
Latest revision as of 21:20, 10 October 2023
This template includes the contents passed to {{{1}}}
only if the final transcluding page is in the Main namespace.
This is useful because many categories are only meaningful in the main namespace, but you might still want to use the template itself in other namespaces. It also makes it easier to write page-generating templates without the "demo" parameter that prevents categorization.
The template functions by fetching the {{NAMESPACE}}
magic word. NAMESPACE is an empty string for the Main namespace, and the name of the namespace otherwise (e.g. File:, Category:...). Simply checking whether NAMESPACE exists is therefore sufficient to detect whether the page is in the main namespace. Additionally, magic words are evaluated in the final page they are transcluded into.
For convenience, Template:Main only points to this template.
No description.
Parameter | Description | Type | Status | |
---|---|---|---|---|
content | 1 | What to paste into the output page if it is in the main namespace. Usually a category. | Unknown | optional |