S

Switch

By Thomas Jakobi (jako)


Parameters

The Snippet uses the following parameters:

&get = input parameter

&c1, &c2, &c3 = switch cases

&do1, &do2, &do3 = output for matching case

The cases don't have to be numeric and you could use an unlimited list of cases. A &cxxx case must have an appropriate &doxxx parameter.

&default (optional) = returned default value, if no matching case is found, if the &doxxx parameter is missing or if the &get parameter is empty

Examples

[[!switch? &get=`3` &c1=`1`  &do1=`one` &c2=`2` &do2=`two` &c3=`3` &do3=`three`  &c4=`4` &do4=`four` &default=`default value`]]

returns 'three'

[[!switch? &get=`xxx` &c1=`1`  &do1=`one` &c2=`2` &do2=`two` &c3=`3` &do3=`three`  &c4=`4` &do4=`four` &default=`default value`]]

returns 'default value'

Thomas Jakobi


New in Switch 1.1.0

  • The switch cases do not need to be sequential or numeric

More

Information

Released
June 24, 2015
Supported Versions
2.2 – Current
Downloads
6,133
License
GPLv2

Previous Versions

1.0.0-beta1
March 31, 2011
2.0 – Current
More

More from Thomas Jakobi

SuperBoxSelect

Advanced Listbox/Resource List template variable

View
L
LangRouter

Language context router for use with Babel

View
DaterangeTV

Date range custom template variable

View
Image+

Advanced Image Template Variable

View