Difference between revisions of "Template:Honor infobox"

From Pathfinder Wiki
(fix missing translation for pilot author and state (both don't need to be translated...))
 
(30 intermediate revisions by 2 users not shown)
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).
 
 
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><div style="max-width: 300px"></nowiki>
::|honorname=Camping Skills IV<br/>
+
:<nowiki>{{</nowiki>Honor infobox<br/>
 +
::|honorlandingpage=AY Honors/Camping Skills IV<br/>
 
::|skill=2<br/>
 
::|skill=2<br/>
 
::|year=2001<br/>
 
::|year=2001<br/>
Line 19: Line 18:
 
::|master1=Wilderness<br/>
 
::|master1=Wilderness<br/>
 
:}}
 
:}}
 +
<nowiki></div></nowiki>
 
</div>
 
</div>
 
+
<div style="max-width: 300px">
<!--T:4-->
+
{{Honor infobox
{{{{FULLPAGENAME}}
+
|honorlandingpage=AY Honors/Camping Skills IV
|honorname=Camping Skills IV
 
 
|skill=2
 
|skill=2
 
|year=2001
 
|year=2001
Line 30: Line 29:
 
|insignia=Camping_Skills_IV.png
 
|insignia=Camping_Skills_IV.png
 
|insignia_source=foo
 
|insignia_source=foo
 +
|master1=Wilderness
 
}}
 
}}
{{{{FULLPAGENAME}}
+
</div>
|honorname=Rock Climbing
+
<!--T:4-->
|skill=2
+
[[Category:UsesLoops]]</noinclude>
|year=1970
+
<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 separated 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|dontTranslate=true}}}}}}}{{#vardefine:honorstate|{{{state|{{GetHonorMetaData|dontTranslate=true|parameter=state}}}}}}}{{#vardefine:patch|{{#if:{{#var:localInsignia}}|{{#switch:{{#var:localInsignia}}
|category=Recreation
 
|authority=North American Division
 
|insignia=Rock_Climbing_Honor.png
 
|insignia_source=foo
 
}}
 
{{{{FULLPAGENAME}}
 
|honorname=Rock Climbing
 
|skill=2
 
|year=1970
 
|category=Recreation
 
|authority=North American Division
 
|insignia=
 
}}
 
</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|{{#if:{{{insignia|}}}|{{#switch:{{{insignia}}}
 
 
|No Patch.png
 
|No Patch.png
|No_Patch.png={{#lst:Localization:All{{GetLangSuffix}}|No Patch}}
+
|No_Patch.png={{Localize|{{#ifeq:{{#var:honorstate}}|piloting|Pilot No Patch|No Patch}}|Images}}
|{{{insignia}}}
+
|{{#var:localInsignia}}
}}|{{#lst:Localization:All{{GetLangSuffix}}|No Patch}}}}}}
+
}}|{{Localize|{{#ifeq:{{#var:honorstate}}|piloting|Pilot No Patch|No Patch}}|Images}}}}}}<!--
 +
check if Not availabel at AdventSource should be shown
 +
-->{{#vardefine:locPilotAuthor|{{#ifeq:{{#var:honorstate}}|piloting|{{{pilotAuthor|{{GetHonorMetaData|dontTranslate=true|parameter=pilotAuthor}}}}}}}|}}{{#vardefine:showNotAdventSrc|{{#ifeq:{{#var:honorstate}}|piloting|true|{{#if:{{{insignia_source|{{GetHonorMetaData|language=/en|parameter=insignia_source}}}}}|true|false}}}}}}
 
<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"
+
{{Infobox
|-
+
|bodyclass=honor-infobox
|colspan="2"  id="infobox-title"|{{{honorname}}}
+
|above={{#ifeq:{{#var:honorstate}}|piloting|{{Localize|NAD Pilot for}}|{{GetHonorName|page={{{honorlandingpage|}}}}}}}
|-
+
|subheader={{#ifeq:{{#var:honorstate}}|piloting|{{GetHonorName|page={{{honorlandingpage|}}}}}}}
| colspan="2" |[[AY Honors/{{{category}}}{{GetLangSuffix}}|{{Localize|{{{category}}}}}]]
+
|subheader2=[[AY Honors/{{#var:localCategory}}{{GetLangSuffix}}|{{Localize|{{#var:localCategory}}}}]]
|-
+
|image={{#ifeq:{{#var:showNotAdventSrc}}|true|{{Superimpose
|colspan="2" style="padding: .5rem 2rem;"|
 
{{#if:{{{insignia_source|}}}
 
  |{{Superimpose
 
 
       | base = {{#var:patch}}
 
       | base = {{#var:patch}}
       | base_width = 150px
+
       | base_width = 100%
       | float = {{#lst:Localization:All{{GetLangSuffix}}|Not available at AdventSource}}
+
      | base_max_width = 150px
 +
       | float = {{Localize|Not available at AdventSource|Images}}
 
       | float_width = 170px
 
       | float_width = 170px
 
       | align=center
 
       | align=center
Line 74: Line 59:
 
   |{{Superimpose
 
   |{{Superimpose
 
       | base = {{#var:patch}}
 
       | base = {{#var:patch}}
       | base_width = 150px
+
       | base_width = 100%
 +
      | base_max_width = 150px
 
       | align=center
 
       | align=center
 
     }}
 
     }}
 
}}
 
}}
|-
+
|col1_label1={{Localize|Skill Level}}
| colspan="2" class="infobox-value text-light bg-secondary" |<span class="infobox-value-emphasize">{{Localize|Skill Level}}</span><br>{{Honor infobox/echoSkillLevel | skill={{{skill}}}}}
+
|col1_data1={{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>{{Localize|{{{authority}}}}}
+
|col1_label2={{#ifeq:{{#var:honorstate}}|piloting||{{Localize|Approval authority}}}}
| class="infobox-value text-light bg-secondary" | <span class="infobox-value-emphasize">{{Localize|Year of Introduction}}</span><br>
+
|col1_data2={{#ifeq:{{#var:honorstate}}|piloting||{{#if:{{{authority|}}}|{{Localize|{{{authority}}}|Authorities}}|{{GetHonorMetaData|parameter=authority}}}}}}
{{#iferror:{{#expr:1+{{{year|X}}} }}|{{Localize|Unknown}}|{{{year}}} }}
+
|col2_label2={{#ifeq:{{#var:honorstate}}|piloting||{{Localize|Year of Introduction}}}}
{{#if:{{#var:locSeeAlsoLess}}|{{!}}-
+
|col2_data2={{#ifeq:{{#var:honorstate}}|piloting||{{#vardefine:localYear|{{{year|{{GetHonorMetaData|language=/en|parameter=year}}}}}}}{{#iferror:{{#expr:1+{{#var:localYear|X}} }}|{{Localize|Unknown}}|{{#var:localYear}} }} }}
{{!}}colspan="2" id="infobox-part-of" class="infobox-value text-light bg-secondary"  {{!}}<span class="infobox-value-emphasize">{{Localize|See also}}</span><br>
+
|rowclass3=honor-infobox-seeAlso
{{#var:locSeeAlsoLess}}{{#if: {{#var:locSeeAlsoMore}}|
+
|col1_label3={{Localize|See also}}
 +
|col1_data3={{#var:locSeeAlsoLess}}{{#if: {{#var:locSeeAlsoMore}}|
 
<div id="infobox-see-also" class="mw-collapsible mw-collapsed" data-expandtext="{{Localize|More}}" data-collapsetext="{{Localize|Less}}"><br>
 
<div id="infobox-see-also" class="mw-collapsible mw-collapsed" data-expandtext="{{Localize|More}}" data-collapsetext="{{Localize|Less}}"><br>
 
{{#var:locSeeAlsoMore}}
 
{{#var:locSeeAlsoMore}}
</div>}} }}
+
</div>}}
|-
+
|col1_noDefaultStyle4=true
| colspan="2" |<div class="dropdown"><htmltag tagname="button" class="btn btn-accent dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{Localize|Downloads}}</htmltag><div class="dropdown-menu" aria-labelledby="dropdownMenuButton"><htmltag tagname="a" href="{{fullurl:{{#titleparts:{{PAGENAME}}|2|1}}/Requirements{{GetLangSuffix}}|action=mpdf}}" class="dropdown-item">{{Localize|Requirements}}
+
|col1_data4={{#ifeq:{{#var:honorstate}}|piloting|<htmltag tagname="a" class="btn btn-accent" href="https://form.jotform.com/220234764665155?honorProposal={{#invoke:String|urlencode|{{#titleparts:{{PAGENAME}}|1|2}}}}" target="_blank">{{Localize|Give Feedback}}</htmltag>|}}
</htmltag><htmltag tagname="a" href="{{fullurl:{{#titleparts:{{PAGENAME}}|2|1}}/Answer Key{{GetLangSuffix}}|action=mpdf}}" class="dropdown-item">{{Localize|Answer Key}}</htmltag></div></div>
+
|col1_class4=honor-infobox-button
|}</div>[[Category:UsesLoops]]
+
|col1_noDefaultStyle5=true
 +
|col1_data5={{#if:{{#var:locPilotAuthor}}|<htmltag tagname="a" class="btn btn-accent" href="{{fullurl:Special:EmailUser/{{#var:locPilotAuthor}}}}" target="_blank">{{Localize|Contact Pilot Author}}</htmltag>|}}
 +
|col1_class5=honor-infobox-button
 +
|col1_noDefaultStyle10=true
 +
|col1_data10={{#ifsysop:<div class="dropdown"><htmltag tagname="button" class="btn btn-accent dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{Localize|Downloads}}</htmltag><div class="dropdown-menu" aria-labelledby="dropdownMenuButton"><htmltag tagname="a" href="{{fullurl:{{#titleparts:{{PAGENAME}}|2|1}}/Requirements{{GetLangSuffix}}|action=mpdf}}" class="dropdown-item">{{Localize|Requirements}}
 +
</htmltag><htmltag tagname="a" href="{{fullurl:{{#titleparts:{{PAGENAME}}|2|1}}/Answer Key{{GetLangSuffix}}|action=mpdf}}" class="dropdown-item">{{Localize|Answer Key}}</htmltag></div></div>|}}
 +
|col1_class10=honor-infobox-button
 +
}}
 +
</div>{{#invoke:Utilities|logger|{{Localize|{{#var:localCategory}}}}}}
 
</includeonly>
 
</includeonly>

Latest revision as of 20:55, 28 April 2022

This template creates an infobox for an honor.

Mechanics

The mechanics are just opaque magic (sorry).

Example

<div style="max-width: 300px">

{{Honor infobox
|honorlandingpage=AY Honors/Camping Skills IV
|skill=2
|year=2001
|category=Recreation
|authority=General Conference
|insignia=Camping_Skills_IV.png
|insignia_source=foo
|master1=Wilderness
}}

</div>


Camping Skills IV
Recreation
Skill Level
123
Approval authority
General Conference
Year of Introduction
2001
See also