If you use modx then here is a handy little extra for you. This simple module allows you to take a csv string and output it iteratively within a tpl.

DOWNLOAD csvToTpl v1.0.1

Simple usage:

[ [!csvToTpl? &csv=`my, text, csv` &tpl=`myTpl.tpl`]]

Use a different tpl for a certain item:

[ [!csvToTpl? &csv=`my, text, csv` &tpl=`myTpl.tpl` &tpl_3=`myTpl3.tpl`]]

note: the first tpl is &tpl_0

tpl variables:

  • [ [+item]] = the item in the CSV array.
  • [ [+itemUCFirst]] = the csv item with the first letter capitalised.
  • [ [+itemUCWords]] = the csv item with the first letter of all words within it capitalised.
  • [ [+itemCaps]] = the csv item with all letters capitalised.
  • [ [+itemClass]] = the csv item made lowercase and all non-alphanumeric characters replaced with a hyphen (-).

Example TPL

<div>
normal: [ [+item]]<br />
ucfirst: [ [+itemUCFirst]]<br />
ucwords: [ [+itemUCWords]]<br />
caps: [ [+itemCaps]] <br />
class friendly: [ [+itemClass]]
<hr>
</div>