Template:Talkspace detect/doc: Difference between revisions

Content deleted Content added
Created page with '{{Documentation subpage}} <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> The {{tl|talkspace detect}} meta-template helps other templates …'
 
m syntaxhighlight lang="wikitext"
 
(13 intermediate revisions by 11 users not shown)
Line 1:
{{Documentation subpage}}
<!--Categories where indicated at the bottom of this page, please; interwikis at Wikidata (see [[Wikipedia:Wikidata]])-->
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
{{high-use}}
 
This is the {{tl|talkspace detect}} meta-template.
The {{tl|talkspace detect}} meta-template helps other templates detect what type of page they are on. It detects and groups all the different [[Wikipedia:Namespace#Enumeration|talkspaces]] used on Wikipedia into several types:
 
The {{tl|talkspace detect}} meta-templateIt helps other templates detect what type of page they are on. It detects and groups all the different [[Wikipedia:Namespace#Enumeration|talkspaces]] used on Wikipedia into several types:
:'''main''' = Defines the output if the template is located on main/article talkspace; aka ''Talk:''.
:'''user''', '''wikipedia''', '''file''', '''mediawiki''', '''template''', '''help''', '''category''' and '''portal''' = Defines the output if the template is located on the specified talkspaces; aka ''User talk:'', ''Wikipedia talk:'', '''File talk:''', etc.
:'''default''' = Defines the output if the template is located on any talkspaces that were not defined as a parameter in this meta-template.
:'''other''' = Defines the output if the template is located on any namespaces (not the associated talkspace).
 
:'''main''' = Defines the output if the template is located on main/article talkspace; aka ''Talk:''.
=== Usage ===
:'''user''', '''wikipedia''', '''file''', '''mediawiki''', '''template''', '''help''', '''category''', '''portal''', '''draft''' and '''portalmodule''' = Defines the output if the template is located on the specified talkspaces; aka ''User talk:'', ''Wikipedia talk:'', '''File talk:''', etc.
:'''default''' = Defines the output if the template is located on any talkspaces that were not defined as a parameter into this meta-template.
:'''other''' = Defines the output if the template is located on any namespacessubject space (not the associated talkspace).
 
=== Usage ===
This template takes one or more parameters named after the different page types as listed above. Like this:
 
<syntaxhighlight lang="wikitext">
<pre>
{{talkspace detect
| main = Article talk page text
| user = User talk page text
| default = Text for all other namespace talk pagestalkspaces
| other = Text for all namespacessubject spaces
}}
</syntaxhighlight>
</pre>
 
By using an empty parameter you can make it so thethis template doesn't render anything for some specific page type. Like this:
 
<syntaxhighlight lang="wikitext">
<pre>
{{talkspace detect
| main =
| default = Text for all other namespace talk pagestalkspaces
}}
</syntaxhighlight>
</pre>
 
=== SeeThe also"page" parameter ===
For testing and demonstration purposes this template can take a parameter named '''page'''. Like this:
 
<syntaxhighlight lang="wikitext">
{{namespace detect see also}}
{{talkspace detect
| user = User talk text.
| default = Any talk page text.
| page = User talk:Example
}}
</syntaxhighlight>
 
No matter on what kind of page the code above is used it will return this:
<includeonly>
 
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
:{{talkspace detect
| user = User talk text.
| default = Any talk page text.
| page = User talk:Example
}}
 
The '''page''' parameter makes this template behave exactly as if on that page. The pagename doesn't have to be an existing page.
 
If the '''page''' parameter is empty or undefined, the name of the current page determines the result.
 
You can make it so your template also understands the '''page''' parameter. That means you can demonstrate the different appearances of your template in the documentation for your template. Then do like this:
 
<syntaxhighlight lang="wikitext">
{{talkspace detect
| user = User talk text.
| default = Any talk page text.
| page = {{{page|}}}
}}
</syntaxhighlight>
 
 
{{Namespace and pagename-detecting templates}}
 
<includeonly>{{Sandbox other|
| <!--Categories below this line, please; interwikis at Wikidata-->
[[Category:Namespace manipulation templates]]
[[Category:Talk namespace templates]]
[[Category:Wikipedia metatemplates]]
 
</includeonly>
}}</includeonly>