Difference between revisions of "Template:Segmented control"

From Co-Optitude Wiki
Jump to navigation Jump to search
Line 21: Line 21:
 
{{#vardefine:imageAndTitle|{{#explode:{{#var:segment}}|;|0}}}}
 
{{#vardefine:imageAndTitle|{{#explode:{{#var:segment}}|;|0}}}}
 
{{#vardefine:segmentLink|{{#explode:{{#var:segment}}|;|1}}}}
 
{{#vardefine:segmentLink|{{#explode:{{#var:segment}}|;|1}}}}
* {{#var:imageAndTitle}} = {{#var:segmentLink}}
+
{{#vardefine:firstChar|{{#sub:{{#var:imageAndTitle}}|0|1}}}}
 
+
{{#vardefine:segmentImage|{{#ifeq:{{#var:firstChar}}|[|{{#explode:{{#sub:{{#var:imageAndTitle}}|1}}|]|0}}|}}
 +
{{#vardefine:segmentTitle|{{#ifeq:{{#var:firstChar}}|[|{{#explode:{{#var:imageAndTitle}}|]|1}}|{{#var:imageAndTitle}}}}
 +
{{#vardefine:segmentSelected|{{#if:{{#var:segmentLink}}|true|false}}}}
 +
* {{#var:segmentTitle}} = {{#var:segmentLink}} ({{#var:segmentSelected}})
 
<div class="rsSegment rsSegmentFirst rsSegmentSelected">
 
<div class="rsSegment rsSegmentFirst rsSegmentSelected">
 
<div class="rsSegmentFill">
 
<div class="rsSegmentFill">

Revision as of 17:06, 28 March 2020

Usage example:

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