Difference between revisions of "Template:Segmented control"

From Co-Optitude Wiki
Jump to navigation Jump to search
Line 3: Line 3:
 
<pre>
 
<pre>
 
{{SegmentedControl
 
{{SegmentedControl
   |Title;Wiki page name
+
   |Titles=Title 1;Title 2;Title 3}}
  |Title$icon.png;Wiki page name
 
  |Selected title
 
  |etc}}
 
 
</pre>
 
</pre>
 
</noinclude>
 
</noinclude>
Line 12: Line 9:
 
{{#vardefine:segmentCount|0}}
 
{{#vardefine:segmentCount|0}}
 
{{#vardefine:i|1}}
 
{{#vardefine:i|1}}
{{#while:|{{{{{#var:i}}|}}} }}
+
{{#while:|{{#vardefine:segmentTitle|{{#explode:{{{Titles}}}|;|{{#var:i}} }} }}{{#var:segmentTitle}}
 
   |<nowiki/>
 
   |<nowiki/>
* Count {{#var:i}} ({{#var:segmentCount}}) - arg = {{{{{#var:i}}|}}}
+
* Title = {{#var:segmentTitle}}
  {{#vardefine:segmentCount|{{#var:i}}}}
 
 
   {{#vardefine:i|{{#expr:{{#var:i}}+1}}}}
 
   {{#vardefine:i|{{#expr:{{#var:i}}+1}}}}
 
}}
 
}}
 
+
</includeonly>
* Segment count is {{#var:segmentCount}}
 
<div class="rsToggleContainer" style="text-align: center;">
 
{{#vardefine:i|1}}
 
{{#while:|{{#ifexpr:{{#var:i}}<={{#var:segmentCount}}|true}}
 
  |<nowiki />
 
  Loop {{#var:i}}
 
  {{#vardefine:i|{{#expr:{{#var:i}}+1}} }}
 
}}
 
</div></includeonly>
 

Revision as of 18:45, 28 March 2020

Usage example:

{{SegmentedControl
  |Titles=Title 1;Title 2;Title 3}}