Combining MIGX and Template Variables in MOD Revo

Scenario: I have a Template Variable on a page(id 13) called ImageGrid that I need to call from other page(s) but only show some of the content. I will choose which rows using a another Template Variable called WorkThumbs.

ImageGrid

I won't run through how to build this yet, but I use getImageList for the response.

WorkThumbs

Input Type:
@EVAL return $modx->runSnippet('SelectWork');
Output Type: Delimiter
Delimiter: ,

SelectWork

$q = "SELECT value FROM modx_site_tmplvar_contentvalues WHERE id='502'";
$query = new xPDOCriteria($modx, $q);
if ($query->stmt && $query->stmt->execute()){
while($row = $query->stmt->fetch(PDO::FETCH_ASSOC)) {
$all = json_decode($row['value']);
}
}
$options = ";
foreach($all as $var => $value)
{
$document = $modx->getObject('modResource',array('id' => $all[$var]->link));
$options .= $document->get('pagetitle').'=='.$all[$var]->link.'||';
}
return substr($options, 0, -2);

Snippet Call

[[!getImageList?&tvname=`ImageGrid`&tpl=`thumbTpl`&where=`{"link:in":"[[*WorkThumbs]]"}`&docid=`13`]]

thumbTpl

<div><a href="[[~[[+link]]]]" title="[[+text]]"><img src="[[+image]]" rel="[[+rollover]]" alt="[[+text]]" /></a></div>

Tags: ,

About Keiron

Web Developer based in the UK. Click here if you want to work with me