Jump to content

Template:Namespace detect/doc: Difference between revisions

no edit summary
(edit cat)
No edit summary
Line 17: Line 17:
'''Note!''' For most usage cases it might be better to use the simpler namespace detection templates. (See the [[#See also|see also]] section below.) Since this template is more prone to human errors such as misspelling the parameter names.  
'''Note!''' For most usage cases it might be better to use the simpler namespace detection templates. (See the [[#See also|see also]] section below.) Since this template is more prone to human errors such as misspelling the parameter names.  


=== Usage ===
=== Usage ===


This template takes one or more parameters named after the different page types as listed above. Like this:
This template takes one or more parameters named after the different page types as listed above. Like this:  
 
<pre>{{namespace detect
<pre>
{{namespace detect
| main  = Article text
| main  = Article text
| talk  = Talk page text
| talk  = Talk page text
Line 28: Line 26:
}}
}}
</pre>
</pre>
 
If the template is on a main (article) page, it will return this:  
If the template is on a main (article) page, it will return this:


:{{namespace detect| demospace=main
:{{namespace detect| demospace=main
| main = Article text
| main = Article text
| talk = Talk page text
| talk = Talk page text
| other = Other pages text
| other = Other pages text
}}
}}


If the template is on any other page than an article or a talk page it will return this:
If the template is on any other page than an article or a talk page it will return this:  


:{{namespace detect
:{{namespace detect
| main = Article text
| main = Article text
| talk = Talk page text
| talk = Talk page text
| other = Other pages text
| other = Other pages text
}}
}}


The example above made the template return something for all page types. But if we don't use the '''other''' parameter or leave it empty then it will not return anything for the other page types. Like this:
The example above made the template return something for all page types. But if we don't use the '''other''' parameter or leave it empty then it will not return anything for the other page types. Like this:  
 
<pre>{{namespace detect
<pre>
{{namespace detect
| file    = File page text
| file    = File page text
| category = Category page text
| category = Category page text
Line 54: Line 49:
}}
}}
</pre>
</pre>
On any pages other than file and category pages the code above will render nothing. <!-- Do not remove this one. It is supposed to render nothing, but we have it here for testing purposes. -->


On any pages other than file and category pages the code above will render nothing.
<!-- Do not remove this one. It is supposed to render nothing, but we have it here for testing purposes. -->
:{{namespace detect
:{{namespace detect
| file     = File page text
| file = File page text
| category = Category page text
| category = Category page text
| other   =
| other =
}}
}}


By using an empty parameter you can make it so the template doesn't render anything for some specific page type. Like this:
By using an empty parameter you can make it so the template doesn't render anything for some specific page type. Like this:  
 
<pre>{{namespace detect
<pre>
{{namespace detect
| main  =  
| main  =  
| other = Other pages text
| other = Other pages text
}}
}}
</pre>
</pre>
 
The code above will render nothing when on mainspace (article) pages, but will return this when on other pages:  
The code above will render nothing when on mainspace (article) pages, but will return this when on other pages:


:{{namespace detect
:{{namespace detect
| main =  
| main =  
| other = Other pages text
| other = Other pages text
}}
}}
1

edit