Template:Link: Difference between revisions

From Heroes of Might and Magic: Olden Era Official Wiki
N (talk | contribs)
Added support for specifying link text
refactored the Link family
Line 1: Line 1:
<noinclude>
<includeonly><!--
-->{{LinkIcon
|id={{{id|}}}
|lang={{{lang|}}}
|text={{{text|}}}
|link={{{link|}}}
|filename=0
|type={{{type|}}}
|color={{{color|}}}
}}<!--
####################################################################
--></includeonly><noinclude>
This template is meant to handle the linking of articles in a way that is language-agnostic, meaning that it can be used in language-aware infoboxes and other contexts which need to be able to handle multiple languages.  This template only works with concepts which have their translation managed by Cargo.
This template is meant to handle the linking of articles in a way that is language-agnostic, meaning that it can be used in language-aware infoboxes and other contexts which need to be able to handle multiple languages.  This template only works with concepts which have their translation managed by Cargo.


If '''nolink''' is provided, it will render with no link. If '''link''' is provided, it will override the lookup (normally linking to the English article, optionally with the specific-language subarticle). If '''text''' is provided, the link will be rendered as the specified text.
{{Note_box | This template is just a wrapper for <code><nowiki>{{LinkIcon | filename=0 | ...}}</nowiki></code>. For more examples, see [[Template:LinkIcon]].}}


{{Color|yellow|Input:}} <code><nowiki>{{Link | id=human | type=faction}}</nowiki></code>


<pre><nowiki>{{Link|type=faction|id=human}}</nowiki></pre>
{{Color|lime|Output:}} {{Link | id=human | type=faction}}


{{Link|type=faction|id=human}}
</noinclude>
 
<pre><nowiki>{{Link|type=spell|id=bonus_spell_astral_summon_1|text=Summon Avatar (Spell)}}</nowiki></pre>
 
{{Link|type=spell|id=bonus_magic_astral_summon_1|text=Summon Avatar (Spell)}}
 
<pre><nowiki>{{Link|type=ui|id=starting_army|nolink}}</nowiki></pre>
 
{{Link|type=ui|id=starting_army|nolink}}
 
<pre><nowiki>{{Link|type=faction|id=human|lang=pl}}</nowiki></pre>
 
{{Link|type=faction|id=human|lang=pl}}
 
 
<pre><nowiki>{{Link|type=ui|id=stats|link=Hero Basics#Attributes}}</nowiki></pre>
 
{{Link|type=ui|id=stats|link=Hero Basics#Stats}}
 
</noinclude><includeonly>{{#cargo_query:
tables  = Translation=T_en, Translation=T_disp
|join on = T_en.target_id = T_disp.target_id
|where  = (T_en.target_id  = '{{{id}}}' OR T_en.subtype = '{{{id}}}')
          AND T_en.type    = '{{{type}}}'  AND T_en.language  = 'en'
          AND T_disp.type  = '{{{type}}}'  AND T_disp.language = '{{{lang|en}}}'
|fields  =
    IF(CONCAT('{{{1|}}}') != '', '', IF('{{{link|}}}' != '', '{{{link}}}',T_en.name)) = link,
    T_disp.name = text,
    T_disp.language = lang,
    {{#if:{{{color|}}} | CONCAT('{{{color}}}') = color }}
    {{#if:{{{text|}}} | CONCAT('{{{text}}}') = text }}
|format  = template
|template= Link/render
|named args = yes
|limit  = 1
|more results text=
}}</includeonly>

Revision as of 13:07, 26 June 2026

This template is meant to handle the linking of articles in a way that is language-agnostic, meaning that it can be used in language-aware infoboxes and other contexts which need to be able to handle multiple languages. This template only works with concepts which have their translation managed by Cargo.

Notes:
    This template is just a wrapper for {{LinkIcon | filename=0 | ...}}. For more examples, see Template:LinkIcon.

Input: {{Link | id=human | type=faction}}

Output: Temple