Template:Advanced link: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><onlyinclude><span dir="{{Text-dir|ltr=ltr|rtl=rtl}}" style="white-space:nowrap">{{#switch:{{{1|}}}|name=|#default={{#if:{{{icon|}}}|<span style="user-select:none">[[File:{{{icon}}}|{{#if:{{{icon size|}}}|{{{icon size}}}|16}}px|link={{#switch: {{#titleparts:{{{link|}}}|1|1}}|Ext={{#titleparts:{{{link|}}}||2}}|#default={{{link|}}}}}]]{{#switch:{{{1|}}}|icon=|#default=&#32;}}</span>}}}}{{#switch:{{{1|}}}|icon=|#default=<span style="line-height:16px; {{#switch:{{{2|}}}|colored=font-weight:bold}}">{{#switch:{{#titleparts:{{{link|}}}|1|1}}|={{{name|}}}|Ext=[{{#titleparts:{{{link|}}}||2}} <span style="{{#switch:{{{2|}}}|colored=color:{{{color|#5081D1}}}}}">{{{name|}}}</span>]|#default=[[:{{{link|}}}|<span style="{{#switch:{{{2|}}}|colored=color:{{{color|#5081D1}}}}}">{{{name|}}}</span>]]}}<wbr></span>}}</span></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 [[Template: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.


== Parameters ==
== Child Templates Usage ==
* {{Param}}, {{Param|2}} – specially prepared code is written into these parameters for the convenient ability to select styles and display type in child templates (see example below).
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.
* {{Param|name}} – The name that will be displayed. It is recommended to use the String template in this parameter to add a name translation.
* {{Param|link}} – The link that will be used. It is recommended to combine this parameter with #switch: if you want to add the ability to specify more than one link. For example, links to categories related to this game.
* {{Param|icon}} – An icon that will be displayed next to the game name. Also clickable. You only need to enter the name and format of the image, for example, {{Code|SomeImage.png}}
* {{Param|icon size}} – icon size (default is 16px). Only accepts px. In this parameter the same parameter is specified for the ability to specify the size of the icon in child templates.
* {{Param|color}} – The color that is used for certain styles of this template. Supports hex, rgb, hsl, etc.
 
== Example ==
{{CodeBlock|src=Template:Portal2 (not the actual one)|lines=9|<nowiki>{{Software inline
| {{{1|}}}
| {{{2|{{{1|}}}}}}
| color = #23B1E5
| icon = Portal2-16px.png
| icon size = {{{icon size|}}}
| link = {{{link|Portal 2}}}
| name = {{{String|en=Portal 2|ru=Портал 2}}
}}</nowiki>}}
 
== Child Usage ==
These examples are written directly using this template, since the <nowiki>{{Portal2}}, {{Hl2}}, {{Hammer}}</nowiki> and other templates do not currently use this template as their base.
{{Table
{{Table
| {{tr|
| {{tr|
Line 30: Line 11:
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Portal2}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Portal 2}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#23B1E5|icon=Portal2-16px.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| Regular internal link. }}
  {{td| Link with icon. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Idtech3}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Portal 2|styled}}</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|styled|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| Link to Wikipedia article. }}
  {{td| Colored link. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Cs2d}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Portal 2|icon}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#FFD700|icon=CS2D icon.png|link=ext/https://store.steampowered.com/app/666220/CS2D|name=CS2D}}! }}
  {{td| This is {{Advanced link|icon|color=#23B1E5|icon=Portal2 icon.png|link=Portal 2|name=Portal 2}}! }}
  {{td| External link. }}
  {{td| Clickable Icon. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Portal2|name}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Portal 2|link}}</nowiki>}} }}
  {{td| This is {{Software inline|name|name|color=#23B1E5|icon=Portal2-16px.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>{{Portal2|icon}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Portal 2|text}}</nowiki>}} }}
  {{td| This is {{Software inline|icon|icon|color=#23B1E5|icon=Portal2-16px.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| Clickable Icon. }}
  {{td| Plain text. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Portal2|colored}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Idtech3}}</nowiki>}} }}
  {{td| This is {{Software inline|colored|colored|color=#23B1E5|icon=Portal2-16px.png|link=Portal 2|name=Portal 2}}! }}
  {{td| This is {{Advanced link|color=#D00000|icon=Quake3-16px.png|link=w:Id Tech 3|name=Id Tech 3}}! }}
  {{td| Link with colored text. }}
  {{td| Link to Wikipedia article. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Portal2|name|colored}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Cs2d}}</nowiki>}} }}
  {{td| This is {{Software inline|name|colored|color=#23B1E5|icon=Portal2-16px.png|link=Portal 2|name=Portal 2}}! }}
  {{td| This is {{Advanced link|color=#FFD700|icon=CS2D icon.png|external=|link=https://store.steampowered.com/app/666220/CS2D|name=CS2D}}! }}
  {{td| Link without icon and with colored text. }}
  {{td| External link. }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Hl2|mode=short}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#FFCC14|icon=Hl2-16px.png|link=Half-Life 2|name={{#switch:short|short=HL2|#default=Half-Life 2}} }}! }}
  {{td| Link with custom display mode “short”. }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Hl2|colored|mode=short}}</nowiki>}} }}
  {{td| This is {{Software inline|colored|colored|color=#FFCC14|icon=Hl2-16px.png|link=Half-Life 2|name={{#switch:short|short=HL2|#default=Half-Life 2}} }}! }}
  {{td| Link with colored text and custom display mode “short”. }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Hammer|colored}}</nowiki>}} }}
  {{td| This is {{Software inline|colored|colored|color=#6165AD|icon=Hammer-16px.png|link=Valve Hammer Editor|name=Hammer}}! }}
  {{td| Link with colored text. }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Hammer|mode=full}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#6165AD|icon=Hammer-16px.png|link=Valve Hammer Editor|name={{#switch:full|full=Valve Hammer Editor|#default=Hammer}} }}! }}
  {{td| Link with custom display mode “full”. }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Hammer|mode=old}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#{{#switch:old|old=7EA465|#default=6165AD}}|icon={{#switch:old|old=Icon-Hammer_3.x.png|#default=Hammer-16px.png}}|link=Valve Hammer Editor|name={{#switch:old|old=Worldcraft|#default=Hammer}} }}! }}
  {{td| Link with custom display mode “old”. }}
}}
}}
{{tr|
{{tr|
  {{td| {{Code|<nowiki>{{Hammer|mode=3x}}</nowiki>}} }}
  {{td| {{Code|<nowiki>{{Pcgw|Portal 2|Test}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#{{#switch:3x|3x=7EA465|#default=6165AD}}|icon={{#switch:3x|3x=Icon-Hammer_3.x.png|#default=Hammer-16px.png}}|link=Valve Hammer Editor|name={{#switch:3x|3x=Hammer 3.x|#default=Hammer}} }}! }}
  {{td| This is {{Advanced link|icon=pcgw icon.png|external=|link=https://www.pcgamingwiki.com/wiki/Portal_2|name=Test}}! }}
  {{td| Link with custom display mode “3x”. }}
  {{td| External link. Unlike the previous examples, it uses a different parameter format. }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Portal2|link=category}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#23B1E5|icon=Portal2-16px.png|link={{#switch:category|category=Category:Portal 2|#default=Portal 2}}|name=Portal 2}}! }}
  {{td| Custom link leading to a place defined by the word “category” (In this case, this is a link to “Category:Portal 2”). }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Portal2|colored|link=games}}</nowiki>}} }}
  {{td| This is {{Software inline|colored|colored|color=#23B1E5|icon=Portal2-16px.png|link={{#switch:games|games=Category:Portal 2 engine branch games|#default=Portal 2}}|name=Portal 2}}! }}
  {{td| Custom link leading to a place defined by the word “games” (In this case, this is a link to “Category:Portal 2 engine branch games”). }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Portal2|link=}}</nowiki>}} }}
  {{td| This is {{Software inline|color=#23B1E5|icon=Portal2-16px.png|link=|name=Portal 2}}! }}
  {{td| No Link and without style. }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Portal2|icon size=32}}</nowiki>}} }}
  {{td| This is {{Software inline|icon size=32|color=#23B1E5|icon=Portal2-16px.png|link=Portal 2|name=Portal 2}}! }}
  {{td| Link with custom icon size. }}
}}
{{tr|
  {{td| {{Code|<nowiki>{{Portal2|colored|icon size=32}}</nowiki>}} }}
  {{td| This is {{Software inline|colored|colored|icon size=32|color=#23B1E5|icon=Portal2-16px.png|link=Portal 2|name=Portal 2}}! }}
  {{td| Link with colored text and custom icon size. }}
}}
{{tr|
  {{td|radius=0 0 0 3px| {{Code|<nowiki>{{Portal2|icon|icon size=24}}</nowiki>}} }}
  {{td| This is {{Software inline|icon|icon size=24|color=#23B1E5|icon=Portal2-16px.png|link=Portal 2|name=Portal 2}}! }}
  {{td|radius=0 0 3px 0| Icon with custom size. }}
}}
}}
}}
}}
== Description ==
{| class="standard-table"
|-
! Parameter
! Description
|-
| {{Code|{{P| {{Param|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.
* {{Code|icon}} – Displays only the icon.
* {{Code|link}} – Displays only the link.
* {{Code|text}} – Displays link text only.
* {{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 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>}}}}
| Used to colorize a link in {{Code|styled}} mode. Default value is {{Color|r=60|g=120|b=210}}.
|-
| {{Code|{{P| 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 {{Code|File:}} at the beginning.
|-
| {{Code|{{P| icon size | 32}}}}
| Icon size. Don't include px at the end when specifying a parameter. Default value is {{Code|x16px}}.
|-
| {{Code|{{P| external |}}}}
| 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}}}}
| Link. If the {{Param|external}} parameter is specified, this link will be treated as external link.
|-
| {{Code|{{P| name | Portal 2}}}}
| The text that will be displayed for the link.
|}
== Example ==
{{CodeBlock|src=Template:Portal 2 ''(not the actual one)''|lines=7|<nowiki>{{Advanced link
| {{{1|{{{show|}}}}}}
| color = #23B1E5
| icon = Portal2 icon.png
| link = Portal 2
| name = {{#switch:{{Language}}|#default=Portal 2|Ko=포탈 2}}
}}</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}} }}