Как декодировать json tvsuperselect
[[ReturnAllTv?
                                        &id=`[[+id]]`
                                        &tpl=`row_par`
                                        &exclude=``
                                        &limit=`5`
                                    ]] 
row_par - <li><b>[[+caption]]:</b> [[+value]]</li><?php
$out = '';
$ex = explode(',', $exclude);
if(!$id) $id = $modx->resource->get('id');
if(!$limit) $limit = 100;
$i = 0;
foreach ($modx->getIterator('modTemplateVarResource', array('contentid' => $id)) as $tv) {
    $tvo = $modx->getObject('modTemplateVar', $tv->get('tmplvarid'));
    if(!$tvo) continue;
	if(in_array($tvo->get('name'), $ex)) continue;
	
    $out .= $modx->getChunk($tpl, array(
        'name' =>$tvo->get('name'),
        'caption' => $tvo->get('caption'),
        'value' =>  $tv->get('value')
    ));
	$i++;
	if($i > $limit) break;
}
return $out;Делал вот так:<?php
$out = '';
$ex = explode(',', $exclude);
if(!$id) $id = $modx->resource->get('id');
if(!$limit) $limit = 100;
$i = 0;
foreach ($modx->getIterator('modTemplateVarResource', array('contentid' => $id)) as $tv) {
    $tvo = $modx->getObject('modTemplateVar', $tv->get('tmplvarid'));
    if(!$tvo) continue;
	if(in_array($tvo->get('name'), $ex)) continue;
	
    $out .= $modx->getChunk($tpl, array(
        'name' =>$tvo->get('name'),
        'caption' => $tvo->get('caption'),
        'value' => ($tv->get('tmplvarid') == 48 ? json_decode($tv->get('value')) : $tv->get('value'))
    ));
    
	$i++;
	if($i > $limit) break;
}
return $out;    Комментарии: 1
                Подскажите пожалуйста. Может быть я чтото не так написал? постарался все максимально подробно описать            
                    
                            Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.