I'm following the tutorial for a multi select box from
http://rtfm.modx.com/display/revolution20/Creating+a+multi-select+box+for+related+pages+in+your+template Which i can get to work fine without including any TV's but becuase I intent to give the client the ability to select the case studies we've decided to pretty it up.
Ive read the article at:
https://forums.modx.com/thread/70587/display-resources-selected-through-tv-urgent but I cannot make that work for multiple TV's in the chunk and i;m not sure what im missing.
As it stands at the minute with the modified call below, no items are listed in the TV select box.
My calls and TPL are as follows:
Snippet: ListCaseStudies - based on the above example in the forum post
if (empty($input)) { return 'This article is so unique, that we couldn\'t find anything related to it!'; }
$tpl = $modx->getOption('tpl',$scriptProperties,'CaseStudyTpl');
if ($modx->getChunk($tpl) == '') { return 'We found some related pages, but don\'t know how to present it.'; }
$ids = explode(',', $input);
$output = array();
foreach ($ids as $key => $value) {
$resource = $modx->getObject('modResource',array(
'published' => 1,
'id' => $value));
if ($resource instanceof modResource) {
$fields = $resource->toArray();
$fields['Case-Study-Image'] = $resource->getTVValue('Case-Study-Image');
$fields['Case-Study-Title'] = $resource->getTVValue('Case-Study-Title');
$fields['Case-Study-Intro'] = $resource->getTVValue('Case-Study-Intro');
$output[] = $modx->getChunk($tpl,$fields);
}
}
return implode('',$output);
CaseStudyTpl
<div class="boxgrid caption" onclick="location.href='[[~[[+id]]]]';" style="cursor:pointer;">
<img src="[[+Case-Study-Image]]" alt="[[+Case-Study-Title]]" />
<div class="cover boxcaption">
<h3>[[+Case-Study-Title]]</h3>
<p>[[+Case-Study-Intro]]</p>
[[+pagetitle]] <!-- Added for testing purposes -->
</div>
TV eval call
@EVAL return $modx->runSnippet('ListCaseStudies',array('parent' => 10));
INput:
[[*Case_Study:is=``:then=``:else=`<div class="case-study">
<div class="case-study-title">Case studies</div>
<div class="case-study-content"> [[ListCaseStudies? &input=`[[*Case_Study]]` &tpl=`CaseStudyTpl` ]]</div>
Any help would be apprecaited as i suck at snippets.
I know theres getRelated but i havent worked with that yet so...
[ed. note: Tyreal2012 last edited this post 14 years, 4 months ago.]