Template:Advanced link: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><onlyinclude><b style="white-space:nowrap">{{#switch:{{{1|}}}|link|text=|#default=<span style="{{#ifeq:{{{1|}}}|icon||margin-right:.2em;}} position:relative; bottom:.1em; user-select:none">[[File:{{{icon}}}|{{{icon size|x16}}}px|link={{{link|}}}]]</span>}}{{#ifeq:{{{1|}}}|icon||{{#ifeq:{{{1|}}}|text|{{{name|}}}|{{#if:{{{external|}}}|<span class="plainlinks">[{{{link}}} {{#ifeq:{{{1|}}}|styled|<span style="color:{{{color|#3C78D2}}}">{{{name|}}}</span>|{{{name|}}}}}]</span>|[[:{{{link}}}|{{#ifeq:{{{1|}}}|styled|<span style="color:{{{color|#3C78D2}}}">{{{name|}}}</span>|{{{name|}}}}}]]}}}}}}</b></onlyinclude></includeonly>
<includeonly><onlyinclude>{{#switch:{{{1|}}}|link|text=|#default=<b style=position:relative;top:-.1em;user-select:none>[[File:{{{icon}}}|{{{icon size|x16}}}px|link={{{link}}}]]{{#ifeq:{{{1|}}}|icon||&#32;}}</b>}}{{#switch:{{{1|}}}|icon=|text={{{name}}}|#default=[{{#if:{{{external}}}|[:{{{link}}}{{!}}|{{{link}}} <nowiki/>}}{{#ifeq:{{{1|}}}|styled|<b style="color:{{{color|#3C78D2}}}">{{{name}}}</b>|{{{name}}}}}{{{external|]}}}]}}</onlyinclude></includeonly>
This template is an improved and simplified version of template {{T|Software}}.
This template creates a link with additional features. Primarily created as a basis for other link templates: game templates, program templates and external link templates.


== Child Templates Usage ==
== Child Templates Usage ==
These examples are written directly using this template, since the {{T|Portal 2}}, {{T|Idtech3}} and {{T|Cs2d}} do not currently use this template as their base.
These examples are written directly using this template, since the {{T|Portal 2}}, {{T|Idtech3}}, {{T|Cs2d}} and {{T|Pcgw}} do not currently use this template as their base.
{{Table
{{Table
| {{tr|
| {{tr|
Line 12: Line 12:
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Portal 2}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Portal 2}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| This is {{Advanced link|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| Link with icon. }}
  {{td| Link with icon. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Portal 2|styled}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Portal 2|styled}}</nowiki>}} }}
  {{td| This is {{Software inline|styled|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| This is {{Advanced link|styled|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| Colored link. }}
  {{td| Colored link. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Portal 2|icon}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Portal 2|icon}}</nowiki>}} }}
  {{td| This is {{Software inline|icon|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| This is {{Advanced link|icon|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| Clickable Icon. }}
  {{td| Clickable Icon. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Portal 2|link}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Portal 2|link}}</nowiki>}} }}
  {{td| This is {{Software inline|link|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| This is {{Advanced link|link|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| Link without icon. }}
  {{td| Link without icon. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Portal 2|text}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Portal 2|text}}</nowiki>}} }}
  {{td| This is {{Software inline|text|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| This is {{Advanced link|text|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| Plain text. }}
  {{td| Plain text. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Idtech3}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Idtech3}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#D00000|icon=Quake3-16px.png|link=w:Id Tech 3|name=Id Tech 3}}! }}
  {{td| This is {{Advanced link|color=#D00000|icon=Quake3-16px.png|link=w:Id Tech 3|name=Id Tech 3}}! }}
  {{td| Link to Wikipedia article. }}
  {{td| Link to Wikipedia article. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Cs2d}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Cs2d}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#FFD700|icon=CS2D icon.png|external=1|link=https://store.steampowered.com/app/666220/CS2D|name=CS2D}}! }}
  {{td| This is {{Advanced link|color=#FFD700|icon=CS2D icon.png|external=|link=https://store.steampowered.com/app/666220/CS2D|name=CS2D}}! }}
  {{td| External link. }}
  {{td| External link. }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Pcgw|Portal 2|Test}}</nowiki>}} }}
  {{td| This is {{Advanced link|icon=pcgw icon.png|external=|link=https://www.pcgamingwiki.com/wiki/Portal_2|name=Test}}! }}
  {{td| External link. Unlike the previous examples, it uses a different parameter format. }}
}}
}}
}}
}}
Line 53: Line 58:
! Description
! Description
|-
|-
  | {{Code|{{P| {{Param||}} }}}}
  | {{Code|{{P| {{Param|show|}} }}}}
| The first parameter specifies the template display format:
| The first parameter specifies the template display format:
* If the value is empty, the standard option will be displayed: an icon with a link.
* If the value is empty, the standard option will be displayed: an icon with a link.
Line 59: Line 64:
* {{Code|link}} – Displays only the link.
* {{Code|link}} – Displays only the link.
* {{Code|text}} – Displays link text only.
* {{Code|text}} – Displays link text only.
* {{Code|styled}} – Displays an icon and link colored in the color specified by the {{Param|color}} parameter.
* {{Code|styled}} – Displays an icon and bold link colored in the color specified by the {{Param|color}} parameter.
When used in child templates, you must specify {{Code|{{Param||}}}} so that you can change the modes when using them.
When used in child templates, you must specify it as {{Code|{{Param|show|}}}} (or {{Code|{{Param||{{Param|show|}}}}}} if the child template does not use unnamed parameters for anything else) so that you can change the modes when using them.
|-
|-
| {{Code|{{P| color | <color>}}}}
| {{Code|{{P| color | <color>}}}}
Line 71: Line 76:
| Icon size. Don't include px at the end when specifying a parameter. Default value is {{Code|x16px}}.
| Icon size. Don't include px at the end when specifying a parameter. Default value is {{Code|x16px}}.
|-
|-
| {{Code|{{P| external | 1}}}}
| {{Code|{{P| external |}}}}
| If this parameter is specified, the value of the {{Param|link}} parameter will be treated as an external link.
| If this parameter is specified, the value of the {{Param|link}} parameter will be treated as an external link. '''Do not''' enter anything into this parameter, it must be left blank, otherwise it will break the template.
|-
|-
| {{Code|{{P| link | Half-Life 2}}}}
| {{Code|{{P| link | Half-Life 2}}}}
Line 82: Line 87:


== Example ==
== Example ==
{{CodeBlock|src=Template:Portal 2 ''(not the actual one)''|lines=7|<nowiki>{{Software inline
{{CodeBlock|src=Template:Portal 2 ''(not the actual one)''|lines=7|<nowiki>{{Advanced link
| {{{1|}}}
| {{{1|{{{show|}}}}}}
| color = #23B1E5
| color = #23B1E5
| icon = Portal2 icon.png
| icon = Portal2 icon.png
| link = {{Langprefix}}Portal 2
| link = Portal 2
| name = {{#switch:{{Language}}|#default=Portal 2|Ko=포탈 2}}
| name = {{#switch:{{Language}}|#default=Portal 2|Ko=포탈 2}}
}}</nowiki>}}
}}</nowiki>}}

Latest revision as of 10:57, 8 October 2025

This template creates a link with additional features. Primarily created as a basis for other link templates: game templates, program templates and external link templates.

Child Templates Usage

These examples are written directly using this template, since the {{Portal 2}}, {{Idtech3}}, {{Cs2d}} and {{Pcgw}} do not currently use this template as their base.

Description

Parameter Description
| {{{show|}}} The first parameter specifies the template display format:
  • If the value is empty, the standard option will be displayed: an icon with a link.
  • icon – Displays only the icon.
  • link – Displays only the link.
  • text – Displays link text only.
  • styled – Displays an icon and bold link colored in the color specified by the {{{color}}} parameter.

When used in child templates, you must specify it as {{{show|}}} (or {{{1|{{{show|}}}}}} if the child template does not use unnamed parameters for anything else) so that you can change the modes when using them.

| color = <color> Used to colorize a link in styled mode. Default value is #3C78D2.
| icon = Example.png The icon that will be displayed next to the link. You only need to specify the file name and format, do not enter File: at the beginning.
| icon size = 32 Icon size. Don't include px at the end when specifying a parameter. Default value is x16px.
| external = If this parameter is specified, the value of the {{{link}}} parameter will be treated as an external link. Do not enter anything into this parameter, it must be left blank, otherwise it will break the template.
| link = Half-Life 2 Link. If the {{{external}}} parameter is specified, this link will be treated as external link.
| name = Portal 2 The text that will be displayed for the link.

Example

Template:Portal 2 (not the actual one)
  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
{{Advanced link | {{{1|{{{show|}}}}}} | color = #23B1E5 | icon = Portal2 icon.png | link = Portal 2 | name = {{#switch:{{Language}}|#default=Portal 2|Ko=포탈 2}} }}