helo... i'm using modx evo, now i want learn about modx revo..
but, i have a problem in snipet code..
this is my code .
<?php
if ($id == '') {$id = $modx->resource->get('id');}
if ($field == '') {$field = array("ImagesSlide1","ImagesSlide2","ImagesSlide3","ImagesSlide4","ImagesSlide5");}
if ($modx->runSnippet('GetField', array('docid'=>"$id", 'field'=>$field[0])) == '') $id = 5;
$tvPr = $modx->getTemplateVarOutput($field,$docid=$id,$published=1);
// register script
$modx->regClientStartupScript('/assets/js/jquery-slide.js');
$modx->regClientScript('<script type="text/javascript">$(".slide").cycle({fx: "fade"});</script>');
// print 'ambil dari self';
print '<div class="slide">';
foreach ($tvPr as $value){
if ($value !== '') {
print '<img src="'.$value.'" width="922" height="506"/>';
}
}
print '</div>';
unset($value);
?>
can you tell me, where is the problem ?? the error like this.
thank you so much...
Gde
-
☆ A M B ☆
- 24,524 Posts
I think you want this:
$modx->resource->getTVValue('TvName');
hello sotwell and bob
Can you give examples of correct code please ??
thank you
Gde
Try just putting this at the top and leaving out the third argument to the function:
function getTemplateVarOutput($tvNames, $id) {
global $modx;
$values = array();
foreach ($tvNames as $tvName) {
$tv = $modx->getObject('modTemplateVar', array('name' => $tvName));
if ($tv) {
$values[] = $tv->renderOutput($id);
}
}
return $values;
}