Difference between revisions of "Template:Segmented control"

From Co-Optitude Wiki
Jump to navigation Jump to search
Line 21: Line 21:
 
{{#vardefine:segment|{{{{{#var:i}}|}}} }}
 
{{#vardefine:segment|{{{{{#var:i}}|}}} }}
 
* segment = {{#var:segment}}
 
* segment = {{#var:segment}}
{{#vardefine:imageAndTitle|{{#explode:{{#var:segment}}|;|0}}}}
+
{{#vardefine:titleAndImage|{{#explode:{{#var:segment}}|;|0}}}}
 
* imageAndTitle = {{#var:imageAndTitle}}
 
* imageAndTitle = {{#var:imageAndTitle}}
 
{{#vardefine:segmentLink|{{#explode:{{#var:segment}}|;|1}}}}
 
{{#vardefine:segmentLink|{{#explode:{{#var:segment}}|;|1}}}}
 
* segmentLink = {{#var:segmentLink}}
 
* segmentLink = {{#var:segmentLink}}
{{#vardefine:firstChar|{{#sub:{{#var:imageAndTitle}}|0|1}}}}
+
{{#vardefine:segmentTitle|{{#explode:{{#var:titleAndImage}}|$|0}}}}
* firstChar = {{#var:firstChar}}
+
* segmentTitle = {{#var:segmentTitle}}
{{#vardefine:segmentImage|{{#ifeq:{{#var:firstChar}}|(|{{#explode:{{#sub:{{#var:imageAndTitle}}|1}}|)|0}}|}}
+
{{#vardefine:segmentImage|{{#explode:{{#var:titleAndImage}}|$|1}}}}
 
* segmentImage = {{#var:segmentImage}}
 
* segmentImage = {{#var:segmentImage}}
{{#vardefine:segmentTitle|{{#ifeq:{{#var:firstChar}}|(|{{#explode:{{#var:imageAndTitle}}|]|1}}|{{#var:imageAndTitle}}}}
 
* segmentTitle = {{#var:segmentTitle}}
 
 
{{#vardefine:segmentSelected|{{#if:{{#var:segmentLink}}|true|false}}}}
 
{{#vardefine:segmentSelected|{{#if:{{#var:segmentLink}}|true|false}}}}
 
* {{#var:segmentTitle}} = {{#var:segmentLink}} ({{#var:segmentSelected}})
 
* {{#var:segmentTitle}} = {{#var:segmentLink}} ({{#var:segmentSelected}})

Revision as of 17:19, 28 March 2020

Usage example:

{{SegmentedControl
  |Title;Wiki page name
  |[Image.png]Title;Wiki page name
  |Selected title
  |etc}}