Need Help.
Evo 1.0.2
I have TV with:
Template Variable Name:
tools
Input Type:
CheckBox
Input Option Values:
Option1||Option2||Option3||Option4
Widget: Delimeter List ","
With Ditto call I output the list of documents where this TV is used and in Ditto template [+tools+] outputs:
<div>1. Option1,Option4</div>
<div>2. Option2,Option3,Option4</div>
...
How can I output each value of TV [*tools*] in this way:
<div>1. <span class="opt1">Option1</span>,<span class="opt4">Option4</span></div>
<div>2. <span class="opt2">Option2</span>,<span class="opt3">Option3</span>,<span class="opt4">Option4</span></div>
...
Thanks!
Using: MODx Evo 1.0.6 / Revo 2.2.5
2 sharkbait,
Thanks for help, but if I get it right, with your snippet I can’t specify a className for each of Checkbox Option.
For example, if in the some document TV [*tools*] checked values are
Option2 and
Option4 using your code will add classes: "
opt1" and "
opt2".
But I need to be like this:
<div>2. <span class="opt2">Option2</span>, <span class="opt4">Option4</span></div>
Using: MODx Evo 1.0.6 / Revo 2.2.5
@sharkbait You rock!
The widget: "HTML Generic Tag" would not give a different class number.
@Wild Striker Why don’t you want numbers in order based on what shows up?
Quote from: mrhaw at Feb 21, 2010, 01:37 PM
@Wild Striker Why don’t you want numbers in order based on what shows up?
Because every Option*X will have an different Image Icon...
Using: MODx Evo 1.0.6 / Revo 2.2.5
Yeah!!! I did it ))
May be it’s not very optimized but for me it’s working.
<?php
// Use snippet [[UsedTools?id=[+id+] ]] in Ditto call template
// TV values: Flash||HTML||CSS||JS||PHP||MySQL
$output = "";
$document_tvs = $modx->getTemplateVarOutput(true, $id);
$TVvalue = $document_tvs['tools'];
$TVarray = explode(",",$TVvalue);
foreach ($TVarray as $val) {
switch ($val) {
case "Flash":
$output .= "<span class=\"ico-flash\">".$val."</span>";break;
case "HTML":
$output .= "<span class=\"ico-html\">".$val."</span>";break;
case "CSS":
$output .= "<span class=\"ico-css\">".$val."</span>";break;
case "JS":
$output .= "<span class=\"ico-js\">".$val."</span>";break;
case "PHP":
$output .= "<span class=\"ico-php\">".$val."</span>";break;
case "MySQL":
$output .= "<span class=\"ico-mysql\">".$val."</span>";break;
}
}
return $output;
?>
P.S. Thanks for helping
Using: MODx Evo 1.0.6 / Revo 2.2.5