Template:Sandbox/Aurelain/LinkIcon: Difference between revisions
No edit summary |
No edit summary |
||
| Line 7: | Line 7: | ||
E.target_id = T.target_id | E.target_id = T.target_id | ||
|where = | |where = | ||
E.target_id = '{{{id}}}' | |||
{{#if:{{{type|}}} | AND E.type = '{{{type}}}' }} | {{#if:{{{type|}}} | AND E.type = '{{{type}}}' }} | ||
AND E.language = 'en' | AND E.language = 'en' | ||
| Line 18: | Line 18: | ||
|=CONCAT(E.target_id, "{{{suffix|.png}}}")=filename, <!-- automatic behavior --> | |=CONCAT(E.target_id, "{{{suffix|.png}}}")=filename, <!-- automatic behavior --> | ||
|0=<!-- omitted filename --> | |0=<!-- omitted filename --> | ||
|1=CONCAT(E.name, "{{{suffix|.png}}}")=filename<!-- forced English filename --> | |||
|#default=CONCAT("{{{filename}}}")=filename, <!-- overridden filename --> | |#default=CONCAT("{{{filename}}}")=filename, <!-- overridden filename --> | ||
}} | }} | ||
| Line 54: | Line 55: | ||
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. | ||
The default assumption for the icon's file name is that it is identical to the {{b|id}}, plus the <code>.png</code> extension. This can be further configured with the {{b|suffix}} parameter, or be completely overridden by the {{b|filename}} parameter. | The default assumption for the icon's file name is that it is identical to the {{b|id}}, plus the <code>.png</code> extension. This can be further configured with the {{b|suffix}} parameter, or be completely overridden by the {{b|filename}} or {{b|filedetect}} parameter. | ||
===Usage=== | ===Usage=== | ||
| Line 175: | Line 176: | ||
|style="width:100px;"|{{Sandbox/Aurelain/LinkIcon|id=might_undead|suffix=_icon.png|wrap=1}} | |style="width:100px;"|{{Sandbox/Aurelain/LinkIcon|id=might_undead|suffix=_icon.png|wrap=1}} | ||
|} | |} | ||
---- | |||
15. With {{b|1=filename=1}}, to use the English name as filename: | |||
{{Color|yellow|Input:}} <code><nowiki>{{Sandbox/Aurelain/LinkIcon | id=human_hero_1 | type=hero | filename=1}}</nowiki></code> | |||
{{Color|lime|Output:}} {{Sandbox/Aurelain/LinkIcon | id=human_hero_1 | type=hero | filename=1}} | |||
</noinclude> | </noinclude> | ||
Revision as of 21:00, 27 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.
The default assumption for the icon's file name is that it is identical to the id, plus the .png extension. This can be further configured with the suffix parameter, or be completely overridden by the filename or filedetect parameter.
Usage
1. Basic (rarely used, as you usually need to specify type and suffix):
Input: {{Sandbox/Aurelain/LinkIcon | id=magic_demon}}
Output:
Herald
2. With type:
Input: {{Sandbox/Aurelain/LinkIcon | id=skill_assault | type=skill}}
Output:
Offense
3. With suffix, to override the default (.png):
Input: {{Sandbox/Aurelain/LinkIcon | id=angel | suffix=_icon.png}}
Output:
Angel
4. With lang, to override the default (en):
Input: {{Sandbox/Aurelain/LinkIcon | id=magic_demon || lang=ja}}
Output:
ヘラルド
5. With size, to override the default (32px):
Input: {{Sandbox/Aurelain/LinkIcon | id=magic_demon | size=64px}}
Output:
Herald
6. With filename, to override the automated file path:
Input: {{Sandbox/Aurelain/LinkIcon | id=human_hero_1 | type=hero | filename=Ister.png}}
Output:
Ister
7. With zero filename, to disable the icon:
Input: {{Sandbox/Aurelain/LinkIcon | id=magic_demon | filename=0}}
Output: Herald
8. With text, to override the automated text:
Input: {{Sandbox/Aurelain/LinkIcon | id=magic_demon | text=Hello}}
Output:
Hello
9. With zero text, to disable the text:
Input: {{Sandbox/Aurelain/LinkIcon | id=magic_demon | text=0}}
10. With link, to override the automated link:
Input: {{Sandbox/Aurelain/LinkIcon | id=magic_demon | link=Foobar}}
Output:
Herald
11. With zero link, to disable the link:
Input: {{Sandbox/Aurelain/LinkIcon | id=magic_demon | link=0}}
Output:
Herald
12. With color:
Input: {{Sandbox/Aurelain/LinkIcon | id=magic_demon | color=magenta}}
Output:
Herald
13. With stack=1, to switch to a vertical layout:
Input: {{Sandbox/Aurelain/LinkIcon | id=magic_demon | stack=1}}
Output:
Herald
14. With wrap=1, to allow the resulting link to wrap (useful if used without icons):
Input:
{|class=wikitable
|style="width:100px;"|{{Sandbox/Aurelain/LinkIcon|id=might_undead|suffix=_icon.png|wrap=1}}
|}
|}
Output:
15. With filename=1, to use the English name as filename:
Input: {{Sandbox/Aurelain/LinkIcon | id=human_hero_1 | type=hero | filename=1}}
Output:
Function: CargoSQLQuery::run Query: SELECT `T`.`_pageID` AS `cargo_backlink_page_id_T`,`E`.`_pageID` AS `cargo_backlink_page_id_E`,CONCAT(`E`.`name`, ".png")=filename
`E`.`name`=link AS `CONCAT(E name, png )=filename E name=link`,`T`.`name` AS `text`,`T`.`language` AS `lang` FROM `mw4v_cargo__Translation` `E` LEFT OUTER JOIN `mw4v_cargo__Translation` `T` ON ((`E`.`target_id`=`T`.`target_id`)) WHERE `E`.`target_id` = 'human_hero_1' AND `E`.`type` = 'hero' AND `E`.`language` = 'en' AND `T`.`type` = 'hero' AND `T`.`language` = 'en' ORDER BY `T`.`_pageID`,`E`.`_pageID`,CONCAT(`E`.`name`, ".png")=filename `E`.`name`=link,`T`.`name`,`T`.`language` LIMIT 100


