steveosoule
2/3/2015 - 2:11 AM

Miva - Loop Over Comma Separated List

Miva - Loop Over Comma Separated List

<mvt:assign name="l.settings:list_string" value="'apples,oranges,milk,cheese'" />
<mvt:assign name="l.settings:list_items" value="miva_array_deserialize(l.settings:list_string)" />
<mvt:foreach iterator="item" array="list_items">
	&mvt:item;<br>
</mvt:foreach>

<mvt:comment><!-- OR THIS ---></mvt:comment>
  
  <mvt:assign name="l.settings:string" value="'apples,oranges,milk,cheese'" />
  <mvt:assign name="l.settings:item" value="'init'" />
  <mvt:while expr="l.settings:item NE NULL">
  	<mvt:assign name="l.settings:while_counter" value="l.settings:while_counter + 1" />
  	<mvt:assign name="l.settings:item" value="gettoken( l.settings:string, ',', l.settings:while_counter )" />
  	&mvt:item;<br>
  </mvt:while>

<mvt:comment><!-- OR THIS ---></mvt:comment>

  <mvt:assign name="l.settings:text_string" value="'apples,oranges,milk,cheese'" />
  <mvt:assign name="l.settings:separator" value="','" />
  <mvt:assign name="l.settings:occurence_count" value="(len(l.settings:text_string) - len(glosub(l.settings:text_string, l.settings:separator,''))) + 1" />
  <mvt:while expr="l.settings:while_counter LT l.settings:occurence_count">
  	<mvt:assign name="l.settings:while_counter" value="l.settings:while_counter + 1" />
  	<mvt:assign name="l.settings:item" value="gettoken( l.settings:text_string, l.settings:separator, l.settings:while_counter )" />
  	&mvt:item;<br>
  </mvt:while>