Difference between revisions of "Template:Segmented control"

From Co-Optitude Wiki
Jump to navigation Jump to search
Line 18: Line 18:
 
{{#ifexpr:{{#var:i}}=1|{{#vardefine:orderClass|rsSegmentFirst}}}}
 
{{#ifexpr:{{#var:i}}=1|{{#vardefine:orderClass|rsSegmentFirst}}}}
 
{{#ifexpr:{{#var:i}}={{#var:segmentCount}}|{{#vardefine:orderClass|rsSegmentLast}}}}
 
{{#ifexpr:{{#var:i}}={{#var:segmentCount}}|{{#vardefine:orderClass|rsSegmentLast}}}}
 +
* orderClass = {{#var:orderClass}}
 
{{#vardefine:segment|{{{{{#var:i}}|}}} }}
 
{{#vardefine:segment|{{{{{#var:i}}|}}} }}
 +
* segment = {{#var:segment}}
 
{{#vardefine:imageAndTitle|{{#explode:{{#var:segment}}|;|0}}}}
 
{{#vardefine:imageAndTitle|{{#explode:{{#var:segment}}|;|0}}}}
 +
* imageAndTitle = {{#var:imageAndTitle}}
 
{{#vardefine:segmentLink|{{#explode:{{#var:segment}}|;|1}}}}
 
{{#vardefine:segmentLink|{{#explode:{{#var:segment}}|;|1}}}}
 +
* segmentLink = {{#var:segmentLink}}
 
{{#vardefine:firstChar|{{#sub:{{#var:imageAndTitle}}|0|1}}}}
 
{{#vardefine:firstChar|{{#sub:{{#var:imageAndTitle}}|0|1}}}}
 +
* firstChar = {{#var:firstChar}}
 
{{#vardefine:segmentImage|{{#ifeq:{{#var:firstChar}}|[|{{#explode:{{#sub:{{#var:imageAndTitle}}|1}}|]|0}}|}}
 
{{#vardefine:segmentImage|{{#ifeq:{{#var:firstChar}}|[|{{#explode:{{#sub:{{#var:imageAndTitle}}|1}}|]|0}}|}}
 +
* segmentImage = {{#var:segmentImage}}
 
{{#vardefine:segmentTitle|{{#ifeq:{{#var:firstChar}}|[|{{#explode:{{#var:imageAndTitle}}|]|1}}|{{#var:imageAndTitle}}}}
 
{{#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:08, 28 March 2020

Usage example:

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