Template:PageRef: Difference between revisions
SerpentofSet (talk | contribs) testing new PageRef template |
SerpentofSet (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
<onlyinclude> | <onlyinclude> | ||
[[{{#invoke:PageRef|getFilename|{{{target}}}|{{{type|}}}}}|link={{{alttarget|{{{target}}}}}}|{{{size|15px}}}]] [[{{{alttarget|{{{target}}}}}}|{{{altname|}}}]] | [[{{#invoke:PageRef|getFilename|{{{target}}}|{{{type|}}}}}|link={{{alttarget|{{{target}}}}}}|{{{size|15px}}}]] [[{{{alttarget|{{{target}}}}}}|{{{altname|{{{target}}}}}}]] | ||
</onlyinclude> | </onlyinclude> | ||
{{Documentation}} | {{Documentation}} | ||
[[Category:Icon templates]] | [[Category:Icon templates]] |
Revision as of 15:10, 17 October 2024
[[Script error: The function "getFilename" does not exist.|link={{{target}}}|15px]] [[{{{target}}}|{{{target}}}]]
Overview
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 (light)
- If neither the .svg nor the .png exist, the icon will not be added
- The .svg should be both light and dark theme compatible (WIP)
- 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
Examples
In its simplest form: {{PageRef|Lash}}
[[Script error: The function "getFilename" does not exist.|link={{{target}}}|15px]] [[{{{target}}}|{{{target}}}]]
Example where the icon doesn't exist: {{PageRef|Shopkeeper}}
[[Script error: The function "getFilename" does not exist.|link={{{target}}}|15px]] [[{{{target}}}|{{{target}}}]]
Using alt_name: {{PageRef|Lash|alt_name=Jacob}}
[[Script error: The function "getFilename" does not exist.|link={{{target}}}|15px]] [[{{{target}}}|{{{target}}}]]
Using alt_link (hover the link to see): {{PageRef|Lash|alt_link=Cold Front}}
[[Script error: The function "getFilename" does not exist.|link={{{target}}}|15px]] [[{{{target}}}|{{{target}}}]]
Using alt_file_name: {{PageRef|Lash|alt_file_name=Cold Front}}
[[Script error: The function "getFilename" does not exist.|link={{{target}}}|15px]] [[{{{target}}}|{{{target}}}]]
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}}
[[Script error: The function "getFilename" does not exist.|link={{{target}}}|15px]] [[{{{target}}}|{{{target}}}]]
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
[[Script error: The function "getFilename" does not exist.|link={{{target}}}|15px]] [[{{{target}}}|{{{target}}}]]
To not use the file, use:
{{PageRef|My cool page|no_file=true}}
[[Script error: The function "getFilename" does not exist.|link={{{target}}}|15px]] [[{{{target}}}|{{{target}}}]]
Parameters
No description.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Name | name 1 | The localized name of the page to link to, also used to determine the icon.
| String | required |
Do not use file | no_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
| String | optional |
Alternate Name | alt_name | An optional display name to show instead of the page name in the link.
| String | optional |
Alternate Link | alt_link | An optional link to link to instead of the 1st parameter (name).
| String | optional |
Alternate File Name | alt_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.
| String | optional |
Size | size | Size of the icon link, defaulted to '15'px
| Number | optional |