Difference between revisions of "Template:Honor infobox"

From Pathfinder Wiki
(fix absent insignia parameter.)
Line 39: Line 39:
 
|insignia=Rock_Climbing_Honor.png  
 
|insignia=Rock_Climbing_Honor.png  
 
|insignia_source=foo
 
|insignia_source=foo
 +
}}
 +
{{{{FULLPAGENAME}}
 +
|honorname=Rock Climbing
 +
|skill=2
 +
|year=1970
 +
|category=Recreation
 +
|authority=North American Division
 +
|insignia=
 
}}
 
}}
 
</noinclude>
 
</noinclude>
<includeonly><!-- Get the List of Master Honors -->{{#vardefine:master|{{GetMasterCategoryList|category={{{category}}}|master1={{{master1|}}}|master1_group={{{master1_group}}}|master2={{{master2|}}}|master_group2={{{master_group2}}} }} }}<!-- create the string-variables holding the content for the see more section -->{{#vardefine: i | 0 }}{{#vardefine: locSeeAlsoLess |}}{{#vardefine: locSeeAlsoMore |}}<!-- get all interesting links for see also into one variable seperated by | -->{{#vardefine:locSeeAlsoAll|{{#var:master}}{{See Also|honorname={{#titleparts:{{PAGENAME}}|1|2}}}}}}{{#if:{{#explode: {{#var:locSeeAlsoAll}}|%{{!}}%|{{#var:i}} }} | {{#vardefine:locSeeAlsoLess|{{#explode: {{#var:locSeeAlsoAll}}|%{{!}}%|{{#var:i}} }} }}{{#vardefine: i | {{#expr: {{#var: i }} + 1 }} }}{{#while: | {{#explode: {{#var:locSeeAlsoAll}}|%{{!}}%|{{#var:i}} }} | {{#ifexpr: {{#var:i}}<3|<!--yes-->{{#vardefine:locSeeAlsoLess|{{#var:locSeeAlsoLess}}<br>{{#explode: {{#var:locSeeAlsoAll}}|%{{!}}%|{{#var:i}} }} }}|<!--no-->{{#vardefine:locSeeAlsoMore|{{#var:locSeeAlsoMore}}{{#ifexpr:{{#var:i}}>3|<br>}}{{#explode: {{#var:locSeeAlsoAll}}|%{{!}}%|{{#var:i}} }} }} }}{{#vardefine: i | {{#expr: {{#var: i }} + 1 }} }} }} }}<!-- get the patch -->{{#vardefine:patch|{{#switch:{{{insignia}}}
+
<includeonly><!-- Get the List of Master Honors -->{{#vardefine:master|{{GetMasterCategoryList|category={{{category}}}|master1={{{master1|}}}|master1_group={{{master1_group}}}|master2={{{master2|}}}|master_group2={{{master_group2}}} }} }}<!-- create the string-variables holding the content for the see more section -->{{#vardefine: i | 0 }}{{#vardefine: locSeeAlsoLess |}}{{#vardefine: locSeeAlsoMore |}}<!-- get all interesting links for see also into one variable seperated by | -->{{#vardefine:locSeeAlsoAll|{{#var:master}}{{See Also|honorname={{#titleparts:{{PAGENAME}}|1|2}}}}}}{{#if:{{#explode: {{#var:locSeeAlsoAll}}|%{{!}}%|{{#var:i}} }} | {{#vardefine:locSeeAlsoLess|{{#explode: {{#var:locSeeAlsoAll}}|%{{!}}%|{{#var:i}} }} }}{{#vardefine: i | {{#expr: {{#var: i }} + 1 }} }}{{#while: | {{#explode: {{#var:locSeeAlsoAll}}|%{{!}}%|{{#var:i}} }} | {{#ifexpr: {{#var:i}}<3|<!--yes-->{{#vardefine:locSeeAlsoLess|{{#var:locSeeAlsoLess}}<br>{{#explode: {{#var:locSeeAlsoAll}}|%{{!}}%|{{#var:i}} }} }}|<!--no-->{{#vardefine:locSeeAlsoMore|{{#var:locSeeAlsoMore}}{{#ifexpr:{{#var:i}}>3|<br>}}{{#explode: {{#var:locSeeAlsoAll}}|%{{!}}%|{{#var:i}} }} }} }}{{#vardefine: i | {{#expr: {{#var: i }} + 1 }} }} }} }}<!-- get the patch -->{{#vardefine:patch|{{#if:{{{insignia|}}}|{{#switch:{{{insignia}}}
 
|No Patch.png
 
|No Patch.png
 
|No_Patch.png={{#lst:Localization:All{{GetLangSuffix}}|No Patch}}
 
|No_Patch.png={{#lst:Localization:All{{GetLangSuffix}}|No Patch}}
|{{{insignia|{{#lst:Localization:All{{GetLangSuffix}}|No Patch}} }}}
+
|{{{insignia}}}
}}}}
+
}}|{{#lst:Localization:All{{GetLangSuffix}}|No Patch}}}}}}
 
<templatestyles src="Honor infobox/style.css" /><div class="mw-parser-output">
 
<templatestyles src="Honor infobox/style.css" /><div class="mw-parser-output">
 
{| class="honor-infobox"
 
{| class="honor-infobox"

Revision as of 05:33, 28 February 2021

This template creates an infobox for an honor.

Mechanics

We had to be careful when invoking See_Also - it uses the honorname parameter to construct the name of a category under which related honors can be found. But the honorname parameter is translated and the categories are not. So even though See_Also wants an honorname, it always wants it in English, and then it tacks a language suffix to the end of the category. To fix this, we needed to extract See_Also's honorname parameter from the invoking page's title using titleparts to grab the second element.

The remaining mechanics are just opaque magic (sorry).

Example

{{Template:Honor infobox
|honorname=Camping Skills IV
|skill=2
|year=2001
|category=Recreation
|authority=General Conference
|insignia=Camping_Skills_IV.png
|insignia_source=foo
|master1=Wilderness
}}


Camping Skills IV
Recreation
[[File:|170px|link=|alt=|]]
Skill Level
123
Approval authority
Year of Introduction

2001


Rock Climbing
Recreation
[[File:|170px|link=|alt=|]]
Skill Level
123
Approval authority
Year of Introduction

1970


Rock Climbing
Recreation
[[File:|150px|alt=|]]
Skill Level
123
Approval authority
Year of Introduction

1970