Difference between revisions of "Template:Format link"
(Creation (as this is needed)) |
m (Text replacement - "{{/doc}}" to "{{Documentation}}") |
||
Line 1: | Line 1: | ||
<includeonly>{{{{{|safesubst:}}}#invoke:format link|formatLink}}</includeonly><noinclude> | <includeonly>{{{{{|safesubst:}}}#invoke:format link|formatLink}}</includeonly><noinclude> | ||
− | {{ | + | {{Documentation}} |
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --> | <!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --> | ||
</noinclude> | </noinclude> |
Latest revision as of 16:19, 2 March 2023
This template formats a link for use in hatnote templates. It accepts up to three positional parameters, the link, an optional display value, and an optional target override (which if provided, makes the link parameter optional). These parameters may also be supplied by name, as link, display, and target respectively. Links to categories and files are automatically escaped with the colon trick, and links to sections are automatically formatted as page § section, rather than the MediaWiki default of page#section.
This template doesn't work with "subst".
Contents
Usage[edit]
Link only:
{{format link|link}}
Link plus display:
{{format link|link|display}}
Link with an italicized page name:
{{format link|link|italicizepage=yes}}
Link with an italicized section name:
{{format link|link|italicizesection=yes}}
If the link or display values contain an equals sign, you will need to specify the parameter names like this:
{{format link|1=link|2=display}}
Link with a target override:
{{format link|link|display|target}}
Link with parameters supplied by name:
{{format link|link=link|display=display|target=target}}
Examples[edit]
{{format link|BattleTech_Universe}}
→ BattleTech_Universe{{format link|BattleTech_Universe#The_BattleTech_Franchise}}
→ BattleTech_Universe § The_BattleTech_Franchise{{format link|Category:Help}}
→ Category:Help{{format link|BattleTech_Universe#The_BattleTech_Franchise|See here for more info on the BattleTech Franchise}}
→ See here for more info on the BattleTech Franchise{{format link|#The_BattleTech_Franchise|BattleTech_Universe#The_BattleTech_Franchise|The_BattleTech_Franchise}}
→ § The_BattleTech_Franchise{{format link|BattleTech_Universe#The_BattleTech_Franchise|italicizepage=true}}
→ BattleTech_Universe § The_BattleTech_Franchise{{format link|BattleTech_Universe#The_BattleTech_Franchise|italicizesection=true}}
→ BattleTech_Universe § The_BattleTech_Franchise{{format link}}
→ Error: no link or target specified! (help)
Errors[edit]
If this template is used and neither the link parameter (or positional parameter 1) nor the target parameter (or positional parameter 3) is supplied, then the template will return an error message. At least one of those must be supplied.
See also[edit]
- {{Format linkr}} – an arguably better version of this template which converts underscores to spaces and calls {{urldecode}} on the input