I’m still not sure, but you can add the docid to placeholders:
<?php
$tvname = $modx->getOption('tvname', $scriptProperties, '');
$tpl = $modx->getOption('tpl', $scriptProperties, '');
$docid = $modx->getOption('docid', $scriptProperties, $modx->resource->get('id'));
if ($tvname == '' || $tpl == 'xx')
{
return;
}
$tv = $modx->getObject('modTemplateVar', array ('name'=>$tvname));
$outputvalue = $tv->renderOutput($docid);
$items = $modx->fromJSON($outputvalue);
$chunk = $modx->getObject('modChunk', array ('name'=>$tpl));
$template = $chunk->getContent();
$output = '';
if (count($items) > 0) {
switch ($tvname) {
case DatesConcerts:
$output .= '<ul class="DatesConcerts">';
break;
case Discographie:
$output .= '<ul class="Discographie">';
break;
case Galerie:
$output .= '<ul class="Galerie">';
break;
case UrlSiteArtiste:
$output .= '<ul class="SitesArtiste">';
break;
}
foreach ($items as $item)
{
$item['docid']=$docid;
$chunk = $modx->newObject('modChunk');
$chunk->setCacheable(false);
$output .= $chunk->process($item, $template);
}
$output .="</ul>";
}
return $output;
then you can use the snippet getResourceField for example with:
<li>
<a href="[[+url]]" title="[[!getResourceField? &id=`[[+docid]]` &field=`pagetitle`]] - [[+nom]]">[[+url]]</a>
</li>
Is it that, what you mean?
Of course, you can also get the resourceFields in your snippet with
$object=$modx->getObject('modResource',array('id'=>$docid)); and put its values the same way I did with $docid to the placeholders.