|no |n |false |0 = | = |¬ = |yes |y |true |1 = yes |#default = yes
}}|{{{{#ifeq:Template:U|
|
}}[[Special:MyLanguage/Template:u|{{#if: |{{{2}}} |{{#ifexist:Translations:{{#if:Template|Template:}}U/Page display title/en
|{{#ifexpr:{{#if:0|1|0}} and 10!=0
|{{#ifeq:en|en
|U
|{{#if:
|{{#ifeq:0|0
|
| String Module Error: Target string is empty
}}
|{{#if:{{ {{#if:|{{{template}}}|Translations:{{#if:Template|Template:}}U/Page_display_title}} | nsp = 0 }}
|{{ {{#if:|{{{template}}}|Translations:{{#if:Template|Template:}}U/Page_display_title}} | nsp = 0 }}
|Template:u
}}
}}
}}
|{{ {{#if:|{{{template}}}|Translations:{{#if:Template|Template:}}U/Page_display_title}} }}
}}
|{{#if:0
|{{#if:U
|U
|Template:u
}}
|Template:u
}}
}}}}]]{{#ifeq:Template:U|
|
}}}}|{{{{safesubst:#ifexist:Template:u |[{{safesubst:#if:1|https://wiki.pixelbar.nl/index.php?title=Template:U&redirect=no {{safesubst:#if:u|u|Template:u}}}}] |{{safesubst:#if:u |u |Template:U }}
}}}}}}Template:User link/doc: Difference between revisions
m Reverted 4 edits by Georgiagirl41 (talk)(TwinkleGlobal) |
m 1 revision imported |
(No difference)
| |
Latest revision as of 17:05, 7 September 2025
{{#switch:<translate></translate> | = {{#if:{{#ifexpr: ( {{#ifeq:doc|doc|1|0}} or ( {{#ifeq:{{#titleparts:template:user link/doc|-1|-2}}|doc|1|0}} and {{#if:{{#translation:}}|1|0}} ) )|1|}}
|
{{#ifeq:show |show
| <templatestyles src="Module:Message box/ombox.css"></templatestyles>
| File:Codex icon book color-base.svg | <translate> This is a documentation [[<tvar name=2>Special:MyLanguage/Help:Subpages</tvar>|subpage]] for <tvar name=1>Template:User link</tvar>.</translate> {{#if: |<translate> It contains usage information, [[<tvar name=7>Special:MyLanguage/Help:Categories</tvar>|categories]] and other content that is not part of the original <tvar name=1>{{{text1}}}</tvar>.</translate>
|<translate> It contains usage information, [[<tvar name=7>Special:MyLanguage/Help:Categories</tvar>|categories]] and other content that is not part of the original <tvar name=1>Template</tvar> page.</translate>
}} |
}}{{#if: |
| {{#ifexist:Template:User link
| [[Category:{{#switch:Template
| Template | Project = Template
| Module = Module
| User = User
| #default = MediaWiki
}} documentation pages{{#translation:}}]]
| [[Category:Documentation subpages without corresponding pages{{#translation:}}]]
}}
}}
|
}}
| #default=
{{#switch:
| = {{#if:{{#ifexpr: ( {{#ifeq:doc|doc|1|0}} or ( {{#ifeq:{{#titleparts:template:user link/doc|-1|-2}}|doc|1|0}} and {{#if:{{#translation:}}|1|0}} ) )|1|}}
|
{{#ifeq:show |show
| <templatestyles src="Module:Message box/ombox.css"></templatestyles>
| File:Codex icon book color-base.svg | This is a documentation subpage for Template:User link. {{#if: |It contains usage information, categories and other content that is not part of the original {{{text1}}}. |It contains usage information, categories and other content that is not part of the original Template page.}} |
}}{{#if: |
| {{#ifexist:Template:User link
| [[Category:{{#switch:Template
| Template | Project = Template
| Module = Module
| User = User
| #default = MediaWiki
}} documentation pages{{#translation:}}]]
| [[Category:Documentation subpages without corresponding pages{{#translation:}}]]
}}
}}
|
}}
| #default=
Lua error: expandTemplate: template loop detected.
}} }}
| warning Lua error: Module:TNT:172: '''Missing JsonConfig extension, or not properly configured;
Cannot load https://commons.wikimedia.org/wiki/Data:I18n/Shared Template Warning.tab. See https://www.mediawiki.org/wiki/Extension:JsonConfig#Supporting_Wikimedia_templates'''. | {{#ifeq:Pixelbar|MediaWiki|Lua error: Module:TNT:172: '''Missing JsonConfig extension, or not properly configured;
Cannot load https://commons.wikimedia.org/wiki/Data:I18n/Shared Template Warning.tab.
See https://www.mediawiki.org/wiki/Extension:JsonConfig#Supporting_Wikimedia_templates'''.|Lua error: Module:TNT:172: '''Missing JsonConfig extension, or not properly configured;
Cannot load https://commons.wikimedia.org/wiki/Data:I18n/Shared Template Warning.tab.
See https://www.mediawiki.org/wiki/Extension:JsonConfig#Supporting_Wikimedia_templates'''.}}{{#if:| |
Usage
This template provides a way to link to a userpage and display just the username, like {{safesubst:#if:|{{{2}}}|Example}}. This may not help much for a short username like "Example", but it can be more useful with long usernames such as {{safesubst:#if:|{{{2}}}|Guywh0sitsbehindphilip12}}.
Example
- <templatestyles src="Template:Mono/styles.css"></templatestyles>{{[[Template:{{safesubst:#if:|{{{SISTER}}}:Template:user link|user link}}|{{safesubst:#if:|{{{SISTER}}}:Template:user link|user link}}]]|Example}}
or the shortcut form
- <templatestyles src="Template:Mono/styles.css"></templatestyles>{{[[Template:{{safesubst:#if:|{{{SISTER}}}:Template:u|u}}|{{safesubst:#if:|{{{SISTER}}}:Template:u|u}}]]|Example}}
gives
The template's second parameter, which is optional, takes the link's label; for example, a link to the long username used above can be shortened while viewing the text like this:
- <templatestyles src="Template:Mono/styles.css"></templatestyles>{{[[Template:{{safesubst:#if:|{{{SISTER}}}:Template:u|u}}|{{safesubst:#if:|{{{SISTER}}}:Template:u|u}}]]|Guywh0sitsbehindphilip12|Guy}}
which gives
Alternative
The desired result can also be achieved using the pipe trick feature of the MediaWiki software. For example, the wikitext
[[User:Example|]]
gives
TemplateData
{{#switch:<translate></translate> |=
|no |n |false |0 = | = |¬ = |yes |y |true |1 = yes |#default = yes
}}|{{#ifexpr:{{#if:|{{#ifeq:Template:User link/doc|Template:Transclude|0|1}}|not{{#ifexpr: ( {{#ifeq:doc|doc|1|0}} or ( {{#ifeq:{{#titleparts:template:user link/doc|-1|-2}}|doc|1|0}} and {{#if:{{#translation:}}|1|0}} ) )|1|0}}}}|Template:Navbar}}}} {{#if:||<translate> This is the [[<tvar name=1>Special:MyLanguage/Help:TemplateData</tvar>|TemplateData]] documentation for this template used by [[<tvar name=2>Special:MyLanguage/VisualEditor</tvar>|VisualEditor]] and other tools.</translate>}}
User link
{{#ifeq:doc|sandbox||{{#if:{{#ifexpr: (
{{#ifeq:doc|doc|1|0}} or ( {{#ifeq:{{#titleparts:template:user link/doc|-1|-2}}|doc|1|0}} and {{#if:{{#translation:}}|1|0}} ) )|1|}}|[[Category:TemplateData documentation{{#translation:}}]]|[[Category:Templates using TemplateData{{#translation:}}]]}}}} | #default=
{{#switch:
|=
|no |n |false |0 = | = |¬ = |yes |y |true |1 = yes |#default = yes
}}|{{#ifexpr:{{#if:|{{#ifeq:Template:User link/doc|Template:Transclude|0|1}}|not{{#ifexpr: ( {{#ifeq:doc|doc|1|0}} or ( {{#ifeq:{{#titleparts:template:user link/doc|-1|-2}}|doc|1|0}} and {{#if:{{#translation:}}|1|0}} ) )|1|0}}}}|Template:Navbar}}}} {{#if:||This is the TemplateData documentation for this template used by VisualEditor and other tools.}}
User link
{{#ifeq:doc|sandbox||{{#if:{{#ifexpr: (
{{#ifeq:doc|doc|1|0}} or ( {{#ifeq:{{#titleparts:template:user link/doc|-1|-2}}|doc|1|0}} and {{#if:{{#translation:}}|1|0}} ) )|1|}}|[[Category:TemplateData documentation{{#translation:}}]]|[[Category:Templates using TemplateData{{#translation:}}]]}}}} | #default=
Lua error: expandTemplate: template loop detected.
}} }} <templatedata> { "format": "inline", "params": { "1": { "label": "Username", "required": true, "type": "wiki-user-name" }, "2": { "label": "Custom label text", "default": "{{{1}}}", "type": "line" } } } </templatedata>
See also
- Help:Magic words
- {{{{#ifeq:Template:Ping|
|
}}[[Special:MyLanguage/Template:ping|{{#if: |{{{2}}} |{{#ifexist:Translations:{{#if:Template|Template:}}Ping/Page display title/en
|{{#ifexpr:{{#if:0|1|0}} and 10!=0
|{{#ifeq:en|en
|Ping
|{{#if:
|{{#ifeq:0|0
|
| String Module Error: Target string is empty
}}
|{{#if:{{ {{#if:|{{{template}}}|Translations:{{#if:Template|Template:}}Ping/Page_display_title}} | nsp = 0 }}
|{{ {{#if:|{{{template}}}|Translations:{{#if:Template|Template:}}Ping/Page_display_title}} | nsp = 0 }}
|Template:ping
}}
}}
}}
|{{ {{#if:|{{{template}}}|Translations:{{#if:Template|Template:}}Ping/Page_display_title}} }}
}}
|{{#if:0
|{{#if:Ping
|Ping
|Template:ping
}}
|Template:ping
}}
}}}}]]{{#ifeq:Template:Ping|
|
}}}}
- {{{{#ifeq:Template:FlowMention|
|
}}[[Special:MyLanguage/Template:FlowMention|{{#if: |{{{2}}} |{{#ifexist:Translations:{{#if:Template|Template:}}FlowMention/Page display title/en
|{{#ifexpr:{{#if:0|1|0}} and 10!=0
|{{#ifeq:en|en
|FlowMention
|{{#if:
|{{#ifeq:0|0
|
| String Module Error: Target string is empty
}}
|{{#if:{{ {{#if:|{{{template}}}|Translations:{{#if:Template|Template:}}FlowMention/Page_display_title}} | nsp = 0 }}
|{{ {{#if:|{{{template}}}|Translations:{{#if:Template|Template:}}FlowMention/Page_display_title}} | nsp = 0 }}
|Template:FlowMention
}}
}}
}}
|{{ {{#if:|{{{template}}}|Translations:{{#if:Template|Template:}}FlowMention/Page_display_title}} }}
}}
|{{#if:0
|{{#if:FlowMention
|FlowMention
|Template:FlowMention
}}
|Template:FlowMention
}}
}}}}]]{{#ifeq:Template:FlowMention|
|
}}}}