Difference between revisions of "Template:Honor infobox"

From Pathfinder Wiki
Line 3: Line 3:
  
 
==Mechanics==
 
==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 mechanics are just opaque magic (sorry). And Examples won't work because the template get's the honorname from the page title.
 
 
The remaining mechanics are just opaque magic (sorry).
 
  
 
==Example== <!--T:3-->
 
==Example== <!--T:3-->
 
<div class="toccolours">
 
<div class="toccolours">
:<nowiki>{{</nowiki>{{FULLPAGENAME}}<br/>
+
:<nowiki>{{</nowiki>Honor infobox<br/>
 
::|honorname=Camping Skills IV<br/>
 
::|honorname=Camping Skills IV<br/>
 
::|skill=2<br/>
 
::|skill=2<br/>
Line 18: Line 16:
 
::|insignia_source=foo<br/>
 
::|insignia_source=foo<br/>
 
::|master1=Wilderness<br/>
 
::|master1=Wilderness<br/>
 +
:}}
 +
:<nowiki>{{</nowiki>Honor infobox<br/>
 +
::|honorname=Camping Skills IV
 
:}}
 
:}}
 
</div>
 
</div>
  
 
<!--T:4-->
 
<!--T:4-->
{{{{FULLPAGENAME}}
 
|honorname=Camping Skills IV
 
|skill=2
 
|year=2001
 
|category=Recreation
 
|authority=General Conference
 
|insignia=Camping_Skills_IV.png
 
|insignia_source=foo
 
}}
 
{{{{FULLPAGENAME}}
 
|honorname=Camping Skills IV
 
}}
 
{{{{FULLPAGENAME}}
 
|honorname=Rock Climbing
 
|skill=2
 
|year=1970
 
|category=Recreation
 
|authority=North American Division
 
|insignia=Rock_Climbing_Honor.png
 
|insignia_source=foo
 
}}
 
{{{{FULLPAGENAME}}
 
|honorname=Rock Climbing
 
}}
 
 
[[Category:UsesLoops]]</noinclude>
 
[[Category:UsesLoops]]</noinclude>
<includeonly><!-- Get the List of Master Honors -->{{#vardefine:localCategory|{{{category|{{GetHonorMetaData|honor={{{honorname|}}}|language=/en}}}}}}}{{#vardefine:master|{{GetMasterCategoryList|category={{#var:localCategory}}|master1={{{master1|{{GetHonorMetaData|honor={{{honorname|}}}|language=/en|parameter=master1}}}}}|master2={{{master2|{{GetHonorMetaData|honor={{{honorname|}}}|language=/en|parameter=master2}}}}}}}}}<!-- 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}}{{GetHonorSeeAlso|honorname={{{honorname|}}}}}}}{{#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:localInsignia|{{{insignia|{{GetHonorMetaData|honor={{{honorname|}}}|language=/en|parameter=insignia}}}}}}}{{#vardefine:patch|{{#if:{{#var:localInsignia}}|{{#switch:{{#var:localInsignia}}
+
<includeonly><!-- Get the List of Master Honors -->{{#vardefine:localCategory|{{{category|{{GetHonorMetaData|language=/en}}}}}}}{{#vardefine:master|{{GetMasterCategoryList|category={{#var:localCategory}}|master1={{{master1|{{GetHonorMetaData|language=/en|parameter=master1}}}}}|master2={{{master2|{{GetHonorMetaData|language=/en|parameter=master2}}}}}}}}}<!-- 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}}{{GetHonorSeeAlso}}}}{{#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:localInsignia|{{{insignia|{{GetHonorMetaData|language=/en|parameter=insignia}}}}}}}{{#vardefine:patch|{{#if:{{#var:localInsignia}}|{{#switch:{{#var:localInsignia}}
 
|No Patch.png
 
|No Patch.png
 
|No_Patch.png={{#lst:Localization:All{{GetLangSuffix}}|No Patch}}
 
|No_Patch.png={{#lst:Localization:All{{GetLangSuffix}}|No Patch}}
Line 55: Line 32:
 
{| class="honor-infobox"
 
{| class="honor-infobox"
 
|-
 
|-
|colspan="2"  id="infobox-title"|{{{honorname|{{#titleparts:{{GetHonorLandingPage}}||-1}}}}}
+
|colspan="2"  id="infobox-title"|{{#titleparts:{{GetHonorLandingPage}}||-1}}
 
|-
 
|-
 
| colspan="2" |[[AY Honors/{{#var:localCategory}}{{GetLangSuffix}}|{{Localize|{{#var:localCategory}}}}]]
 
| colspan="2" |[[AY Honors/{{#var:localCategory}}{{GetLangSuffix}}|{{Localize|{{#var:localCategory}}}}]]
 
|-
 
|-
 
|colspan="2" style="padding: .5rem 2rem;"|
 
|colspan="2" style="padding: .5rem 2rem;"|
{{#if:{{{insignia_source|{{GetHonorMetaData|honor={{{honorname|}}}|language=/en|parameter=insignia_source}}}}}
+
{{#if:{{{insignia_source|{{GetHonorMetaData|language=/en|parameter=insignia_source}}}}}
 
   |{{Superimpose
 
   |{{Superimpose
 
       | base = {{#var:patch}}
 
       | base = {{#var:patch}}
Line 77: Line 54:
 
}}
 
}}
 
|-
 
|-
| colspan="2" class="infobox-value text-light bg-secondary" |<span class="infobox-value-emphasize">{{Localize|Skill Level}}</span><br>{{Honor infobox/echoSkillLevel | skill={{{skill|{{GetHonorMetaData|honor={{{honorname|}}}|parameter=skill}}}}}}}
+
| colspan="2" class="infobox-value text-light bg-secondary" |<span class="infobox-value-emphasize">{{Localize|Skill Level}}</span><br>{{Honor infobox/echoSkillLevel | skill={{{skill|{{GetHonorMetaData|parameter=skill}}}}}}}
 
|-
 
|-
| class="infobox-value text-light bg-secondary" | <span class="infobox-value-emphasize">{{Localize|Approval authority}}</span><br>{{#if:{{{authority|}}}|{{Localize|{{{authority}}}}}|{{GetHonorMetaData|honor={{{honorname|}}}|parameter=authority}}}}
+
| class="infobox-value text-light bg-secondary" | <span class="infobox-value-emphasize">{{Localize|Approval authority}}</span><br>{{#if:{{{authority|}}}|{{Localize|{{{authority}}}}}|{{GetHonorMetaData|parameter=authority}}}}
 
| class="infobox-value text-light bg-secondary" | <span class="infobox-value-emphasize">{{Localize|Year of Introduction}}</span><br>
 
| class="infobox-value text-light bg-secondary" | <span class="infobox-value-emphasize">{{Localize|Year of Introduction}}</span><br>
{{#vardefine:localYear|{{{year|{{GetHonorMetaData|honor={{{honorname|}}}|language=/en|parameter=year}}}}}}}{{#iferror:{{#expr:1+{{#var:localYear|X}} }}|{{Localize|Unknown}}|{{#var:localYear}} }}
+
{{#vardefine:localYear|{{{year|{{GetHonorMetaData|language=/en|parameter=year}}}}}}}{{#iferror:{{#expr:1+{{#var:localYear|X}} }}|{{Localize|Unknown}}|{{#var:localYear}} }}
 
{{#if:{{#var:locSeeAlsoLess}}|{{!}}-
 
{{#if:{{#var:locSeeAlsoLess}}|{{!}}-
 
{{!}}colspan="2" id="infobox-part-of" class="infobox-value text-light bg-secondary"  {{!}}<span class="infobox-value-emphasize">{{Localize|See also}}</span><br>
 
{{!}}colspan="2" id="infobox-part-of" class="infobox-value text-light bg-secondary"  {{!}}<span class="infobox-value-emphasize">{{Localize|See also}}</span><br>

Revision as of 00:35, 24 March 2021

This template creates an infobox for an honor.

Mechanics

The mechanics are just opaque magic (sorry). And Examples won't work because the template get's the honorname from the page title.

Example

{{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
}}
{{Honor infobox
|honorname=Camping Skills IV
}}