Sjabloon:Talkspace detect/doc
40px | This is a documentation subpage for Sjabloon:Talkspace detect. It contains usage information, categories, interlanguage links and other content that is not part of the original sjabloon page. |
This is the {{talkspace detect}} meta-template.
It helps other templates detect what type of page they are on. It detects and groups all the different 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, portal and book = 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 to this meta-template.
- other = Defines the output if the template is located on any subject space (not the associated talkspace).
Usage
This template takes one or more parameters named after the different page types as listed above. Like this:
{{talkspace detect | main = Article talk page text | user = User talk page text | default = Text for all other talkspaces | other = Text for all subject spaces }}
By using an empty parameter you can make it so this template doesn't render anything for some specific page type. Like this:
{{talkspace detect | main = | default = Text for all other talkspaces }}
The "page" parameter
For testing and demonstration purposes this template can take a parameter named page. Like this:
{{talkspace detect | user = User talk text. | default = Any talk page text. | page = User talk:Example }}
No matter on what kind of page the code above is used it will return this:
- Any talk page text.
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:
{{talkspace detect | user = User talk text. | default = Any talk page text. | page = {{{page|}}} }}
See also
Easy to use namespace-detection templates:
- {{main other}} – For article templates.
- {{talk other}} – For talk page templates.
- {{user other}} – For user page templates.
- {{wikipedia other}} – For detecting "Wikipedia:" pages.
- {{file other}} – For file (image) templates.
- {{template other}} – For detecting template pages.
- {{help other}} – For help page templates.
- {{category other}} – For category templates.
- {{portal other}} – For portal templates.
- {{book other}} – For detecting book pages.
- {{module other}} – For detecting module pages.
More complex namespace-detection templates:
- {{namespace detect}} – The very versatile one.
- {{namespace detect showall}} – The extremely versatile one, has input reuse.
- {{talkspace detect}} - For detecting talk pages on various namespaces.
- {{main talk other}} – Separates some namespaces.
- {{main talk category other}} – Separates some namespaces.
Pagename-handling and detection templates:
- {{basepage subpage}} – For detecting if on a basepage, subpage or subsubpage.
- {{pgn}} – Can take apart and put together pagenames in several ways.
- {{if pagename}} – For pattern matching on the pagename.
- {{if pagename multi}} – For pattern matching on the pagename, has input reuse.
- {{IP-user other}} – For detecting IP-user pages.
- {{IP-talk}} - Return: 1) IP user talk page 2) registered user talk page 3) not user talk page.
Technical stuff:
- Wikipedia:Namespace – Lists all the namespaces.
- mw:Help:Magic words – About
{{NAMESPACE}}
etc. - mw:Help:Extension:ParserFunctions – About
{{#ifeq:|||}}
etc.