Quote from: sharkbait at Feb 21, 2010, 03:53 PM
Yeah!!! I did it ))
great! 
...thought it needs to be dynamic ( e.g. automatically assigning a new class if you add another TV value / without editing the snippet )
I’m not so good at programming so I did what I can.
I will be grateful if you make it dynamic
Using: MODx Evo 1.0.6 / Revo 2.2.5
That code is
excellent for what you want!

I first thought you wanted an integer number for some jQuery function.
This might make it dynamic and a little faster (untested):
<?php
// Use snippet [[UsedTools?id=[+id+] ]] in Ditto call template
// TV Input Option values: Flash==Flash#ico-flash||HTML==HTML#ico-html||CSS==CSS#ico-css||JS==JS#ico-js||PHP==PHP#ico-php||MySQL==MySQL#ico-mysql
$output = "";
$document_tvs = $modx->getTemplateVarOutput(true, $id);
$TVvalue = $document_tvs['tools'];
$TVarray = explode(",",$TVvalue);
foreach ($TVarray as $val) {
$valArray=explode("#",$val);
$output .= '<span class="' . $valArray[0] . '">'. $valArray[1] . '</span>';
}
return $output;
?>
I just noticed that the names are regular, so I think it could also be done even faster with your original input option values like this:
<?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) {
$output .= '<span class="ico-'. strtolower($val) . '">' . $val. '</span>';
}
return $output;
?>
Quote from: BobRay at Feb 22, 2010, 01:26 AM
I just noticed that the names are regular, so I think it could also be done even faster with your original input option values like this:
<?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) {
$output .= '<span class="ico-'. strtolower($val) . '">' . $val. '</span>';
}
return $output;
?>
Thanks a lot! This is perfect !
Using: MODx Evo 1.0.6 / Revo 2.2.5
Quote from: Wild at Feb 22, 2010, 03:20 AM
. . .
Thanks a lot! This is perfect !
Don’t thank me until it works.