Template:PageRef/doc: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
mNo edit summary
more details
 
(21 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Note: It's recommended to use {{tl|HeroIcon}}, {{tl|AbilityIcon}}, or {{tl|ItemIcon}} instead, as those templates use [[Module:Icon]] and thus allow for more elaborate functions such as custom previews. PageRef should only be used for icons not covered in those templates, i.e. {{PageRef|Hidden King}} or {{PageRef|Shopkeeper}}.
=Overview=
=Overview=
Outputs an icon in svg and a link to the given page with an optional alternate display name.
Outputs an icon in svg and a link to the given localized page with an optional alternate display name.


Output should be:<br>
Output will be:<br>
<icon> <pagename>
<icon> <pagename>


* Both icon and page name should be hyperlinked to first parameter as the pagename
* Both icon and page name will be hyperlinked to first parameter as the pagename
* Icon should be <pre style="width: fit-content>[[File:<pagename>.svg]]</pre> if the svg file exists, otherwise the .png.  
* Icon should be <pre style="width: fit-content>[[File:<pagename>.svg]]</pre> if the svg file exists, otherwise the .png.  
* The .svg should be both light and dark theme compatible
** The .svg should be both light and dark theme compatible (WIP)
* The .png should be default theme compatible (light)
***It's possible CSS may be used to automatically invert colors, precluding the need for the icon to be theme-compatible
** The .png should at least be default theme compatible (dark)
** If neither the .svg nor the .png exist, the icon will not be added
* If the first parameter (name) is a hero name in english, it will automatically use the <hero>_MM.png file
** Otherwise, if the file name is different to the page name (do not use this in excess), the <i>alt_file_name</i> parameter will need to be used
 
The code for this template is at [[Module:PageRef]]. The module also lists exceptions for pages that currently do not have an icon uploaded, so that templates such as [[Template:VoiceLineCite]] do not use a broken image link. If an icon for those pages is added, they should be removed from the exceptions list.


=Examples=
=Examples=
In its simplest form: <code><nowiki>{{PageRef|Lash}}</nowiki></code> {{PageRef|Lash}}


{{PageRef|target=Lash|type=Hero|altname=Jacob}}
Example where the icon doesn't exist: <code><nowiki>{{PageRef|Shopkeeper}}</nowiki></code> {{PageRef|Shopkeeper}}
{{PageRef|target=Bullet Lifesteal|type=Item|alttarget=Bullet Lifesteal (item)}}
 
(not yet working)
 
{{PageRef|Lash|alt=Jacob}}
 
{{PageRef|Siphon Life|size=50}}
 
{{PageRef|AttributeIconTechDuration}}


{{PageRef|Basic Magazine}}
Using alt_name: <code><nowiki>{{PageRef|Lash|alt_name=Jacob}}</nowiki></code> {{PageRef|Lash|alt_name=Jacob}}


{{PageRef|The Curiosity Shop|alt=Shop|size=100}}
Using alt_link (hover the link to see): <code><nowiki>{{PageRef|Lash|alt_link=Cold Front}}</nowiki></code> {{PageRef|Lash|alt_link=Cold Front}}


Using alt_file_name: <code><nowiki>{{PageRef|Lash|alt_file_name=Cold Front}}</nowiki></code> {{PageRef|Lash|alt_file_name=Cold Front}}


Below is a fake example. Ideally, the template is called like:
Using them all together, note that the first parameter is no longer used and therefore not needed:  
<code><nowiki>{{PageRef|alt_name=Cold Front|alt_link=Cold Front|alt_file_name=Cold Front}}</nowiki></code>
{{PageRef|alt_name=Cold Front|alt_link=Cold Front|alt_file_name=Cold Front}}


<pre style="width: fit-content">{{PageRef|Lash|alt=Jacob}}</pre>
Note: Instead of repeated use of <i>alt_file_name</i>, it is recommended to create a redirect at <nowiki>[[<first_parameter>.png]]</nowiki> to <nowiki>[[<alt_file_name>.png]]</nowiki>, allowing the use of the simplest form of PageRef, making it much easier to reference in the future.


In wikitext it would look be outputted as:
If a file does not exist, it will look like
<pre style="width: fit-content">[[File:Lash.svg|class=dark_or_light|link=Lash|size=15]] [[Lash|Jacob]]</pre>
{{PageRef|My cool page}}


Which would appear in visual as
To not use the file, use:
<code><nowiki>{{PageRef|My cool page|no_file=true}}</nowiki></code>
{{PageRef|My cool page|no_file=true}}


{{HeroIcon|Lash|Jacob}}
Using lang with to override language (e.g., Russian):
<code><nowiki>{{PageRef|Lash|lang=/ru}}</nowiki></code>
{{PageRef|Lash|lang=/ru}}


=Parameters=
<templatedata>
<templatedata>
{
{
    "params": {
"params": {
        "name": {
"name": {
            "label": "Name",
"label": "Name",
            "description": "The name of the page to link to, also used to determine the icon.",
"description": "The localized name of the page to link to, also used to determine the icon.",
            "type": "string",
"required": true,
            "required": true,
"example": "Lash",
            "example": "Lash"
"aliases": [
        },
"1"
        "alt": {
],
            "label": "Alternate Name",
"type": "string"
            "description": "An optional display name to show instead of the page name in the link.",
},
            "type": "string",
"no_file": {
            "required": false,
"label": "Do not use file",
            "example": "Jacob"
"description": "Do not use any file; also use this parameter when a file doesn't exist. Note that passing 'false' does not make it use a file, the parameter must then be omitted. This is for code efficiency",
        },
"required": false,
        "size": {
"example": "true",
            "label": "Size",
"type": "string"
            "description": "Size of the icon link, defaulted to '15'px",
},
            "type": "number",
"alt_name": {
            "required": false,
"label": "Alternate Name",
            "example": "50"
"description": "An optional display name to show instead of the page name in the link.",
        }
"type": "string",
    },
"required": false,
    "format": "inline"
"example": "Jacob"
},
"alt_link": {
"label": "Alternate Link",
"description": "An optional link to link to instead of the 1st parameter (name).",
"type": "string",
"required": false,
"example": "Death Slam"
},
"alt_file_name": {
"label": "Alternate File Name",
"description": "An optional way to designate which file to include. Not needed if <first parameter> (name) is the same as the file name. File extension not needed, as it will try to prioritize the .svg first, otherwise use the .png.",
"type": "string",
"required": false,
"example": "Amber Hand.png"
},
"size": {
"label": "Size",
"description": "Size of the icon link, defaulted to '20'px",
"type": "number",
"required": false,
"example": "50"
},
"lang": {
"label": "Language",
"description": "An optional language code to override the default language suffix in links (e.g., '/ru', '/zh-hans'). If omitted, `If_lang` template is used.",
"example": "/ru",
"type": "string"
}
},
"format": "inline"
}
}
</templatedata>
</templatedata>

Latest revision as of 13:59, 14 May 2026

Note: It's recommended to use {{HeroIcon}}, {{AbilityIcon}}, or {{ItemIcon}} instead, as those templates use Module:Icon and thus allow for more elaborate functions such as custom previews. PageRef should only be used for icons not covered in those templates, i.e. Hidden King or Shopkeeper.

Overview

[edit source]

Outputs an icon in svg and a link to the given localized page with an optional alternate display name.

Output will be:
<icon> <pagename>

  • Both icon and page name will be hyperlinked to first parameter as the pagename
  • Icon should be
    [[File:<pagename>.svg]]
    if the svg file exists, otherwise the .png.
    • The .svg should be both light and dark theme compatible (WIP)
      • It's possible CSS may be used to automatically invert colors, precluding the need for the icon to be theme-compatible
    • The .png should at least be default theme compatible (dark)
    • If neither the .svg nor the .png exist, the icon will not be added
  • If the first parameter (name) is a hero name in english, it will automatically use the <hero>_MM.png file
    • Otherwise, if the file name is different to the page name (do not use this in excess), the alt_file_name parameter will need to be used

The code for this template is at Module:PageRef. The module also lists exceptions for pages that currently do not have an icon uploaded, so that templates such as Template:VoiceLineCite do not use a broken image link. If an icon for those pages is added, they should be removed from the exceptions list.

Examples

[edit source]

In its simplest form: {{PageRef|Lash}} Lash

Example where the icon doesn't exist: {{PageRef|Shopkeeper}} Shopkeeper

Using alt_name: {{PageRef|Lash|alt_name=Jacob}} Jacob

Using alt_link (hover the link to see): {{PageRef|Lash|alt_link=Cold Front}} Lash

Using alt_file_name: {{PageRef|Lash|alt_file_name=Cold Front}} Lash

Using them all together, note that the first parameter is no longer used and therefore not needed: {{PageRef|alt_name=Cold Front|alt_link=Cold Front|alt_file_name=Cold Front}} Cold Front

Note: Instead of repeated use of alt_file_name, it is recommended to create a redirect at [[<first_parameter>.png]] to [[<alt_file_name>.png]], allowing the use of the simplest form of PageRef, making it much easier to reference in the future.

If a file does not exist, it will look like File:My cool page.pngMy cool page

To not use the file, use: {{PageRef|My cool page|no_file=true}} My cool page

Using lang with to override language (e.g., Russian): {{PageRef|Lash|lang=/ru}} Lash

Parameters

[edit source]

No description.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Namename 1

The localized name of the page to link to, also used to determine the icon.

Example
Lash
Stringrequired
Do not use fileno_file

Do not use any file; also use this parameter when a file doesn't exist. Note that passing 'false' does not make it use a file, the parameter must then be omitted. This is for code efficiency

Example
true
Stringoptional
Alternate Namealt_name

An optional display name to show instead of the page name in the link.

Example
Jacob
Stringoptional
Alternate Linkalt_link

An optional link to link to instead of the 1st parameter (name).

Example
Death Slam
Stringoptional
Alternate File Namealt_file_name

An optional way to designate which file to include. Not needed if <first parameter> (name) is the same as the file name. File extension not needed, as it will try to prioritize the .svg first, otherwise use the .png.

Example
Amber Hand.png
Stringoptional
Sizesize

Size of the icon link, defaulted to '20'px

Example
50
Numberoptional
Languagelang

An optional language code to override the default language suffix in links (e.g., '/ru', '/zh-hans'). If omitted, `If_lang` template is used.

Example
/ru
Stringoptional