Difference between revisions of "Template:Segmented control"

From Co-Optitude Wiki
Jump to navigation Jump to search
Line 11: Line 11:
 
<includeonly>
 
<includeonly>
 
   <div class="rsToggleContainer" style="text-align: center;">
 
   <div class="rsToggleContainer" style="text-align: center;">
    {{#vardefine:segmentCount|0}}
 
 
     {{#vardefine:i|0}}
 
     {{#vardefine:i|0}}
 
     {{#while:|{{#vardefine:segmentTitle|{{#explode:{{{Titles|}}}|;|{{#var:i}} }} }}{{#var:segmentTitle}}
 
     {{#while:|{{#vardefine:segmentTitle|{{#explode:{{{Titles|}}}|;|{{#var:i}} }} }}{{#var:segmentTitle}}
 
       |<nowiki/>
 
       |<nowiki/>
 +
* Segment title: {{#var:segmentTitle}}
 
       {{#vardefine:segmentImage|{{#explode:{{{Icons|}}}|;|{{#var:i}} }} }}
 
       {{#vardefine:segmentImage|{{#explode:{{{Icons|}}}|;|{{#var:i}} }} }}
 +
* Segment image: {{#var:segmentImage}}
 
       {{#vardefine:segmentLink|{{#explode:{{{Links|}}}|;|{{#var:i}} }} }}
 
       {{#vardefine:segmentLink|{{#explode:{{{Links|}}}|;|{{#var:i}} }} }}
 +
* Segment link: {{#var:segmentLink}}
 
       {{#vardefine:segmentClasses|rsSegment {{#if:{{#var:segmentLink}}|rsSegmentSelected}}}}
 
       {{#vardefine:segmentClasses|rsSegment {{#if:{{#var:segmentLink}}|rsSegmentSelected}}}}
 +
* Segment classes: {{#var:segmentClasses}}
 
       {{#vardefine:segmentIconHTML|
 
       {{#vardefine:segmentIconHTML|
 
         {{#if:{{#var:segmentImage}}
 
         {{#if:{{#var:segmentImage}}
Line 23: Line 26:
 
         }}
 
         }}
 
       }}
 
       }}
 +
* Segment icon HTML: {{#var:segmentIconHTML}}
 
       {{#vardefine:segmentFillHTML|
 
       {{#vardefine:segmentFillHTML|
 
         <div class="rsSegmentFill">
 
         <div class="rsSegmentFill">
Line 30: Line 34:
 
         </div>
 
         </div>
 
       }}
 
       }}
 +
* Segment fill HTML: {{#var:segmentFillHTML}}
 
       <div class="{{#var:segmentClasses}}">
 
       <div class="{{#var:segmentClasses}}">
 
         {{#if:{{#var:segmentLink}}|
 
         {{#if:{{#var:segmentLink}}|
Line 36: Line 41:
 
         }}
 
         }}
 
       </div>
 
       </div>
      {{#if:{{#var:segmentLink}}|
 
        [[{{#var:segmentLink}}|{{#var:segmentFillHTML}}]]|
 
        {{#segmentFillHTML}}
 
      }}
 
 
       {{#vardefine:i|{{#expr:{{#var:i}}+1}}}}
 
       {{#vardefine:i|{{#expr:{{#var:i}}+1}}}}
 
     }}
 
     }}
 
   </div>
 
   </div>
 
</includeonly>
 
</includeonly>

Revision as of 19:28, 28 March 2020

Usage example:

{{SegmentedControl
  |Titles=Title 1;Title 2;Title 3
  |Icons=Icon-name.png;;Icon-name.png
  |Links=Name of page;Name of page;}}

Segments without links will be assumed to be selected. Missing icons will show segments without icons.