<templatestyles src="Template:Badge/styles.css"/>
<translate> {{<tvar name=1>PLURAL:1</tvar>|shortcut|shortcuts}}:</translate> <templatestyles src="Template:Mono/styles.css"/>{{#if:{{safesubst:#switch:
|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

From Pixelbar
Revision as of 17:05, 7 September 2025 by NinjaLikesCheez (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

{{#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>

        }}{{#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>

        }}{{#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:|
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'''.}}

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

{{safesubst:#if:|{{{2}}}|Example}}

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

{{safesubst:#if:Guy|Guy|Guywh0sitsbehindphilip12}}

Alternative

The desired result can also be achieved using the pipe trick feature of the MediaWiki software. For example, the wikitext

[[User:Example|]]

gives

Example

TemplateData

{{#switch:<translate></translate> |=

{{#if:{{safesubst:#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:||<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:

|=

{{#if:{{safesubst:#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

 |

}}[[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|

 |

}} }}