No problem but the coding won’t win any awards.
[[!getResources? &resources=`[[!relateReviews? &tvid=`13` &resid=`[[*id]]`]]` &tpl=`relateTpl` &showHidden=`1` &includeContent=`1`]]
where $tvid is the id of my checkbox TV used for relating reviews with products.
The relateReviews snippet, which returns id’s of related resources to getResources, is:
<?php
$stmt = $modx->query("SELECT value FROM catw_site_tmplvar_contentvalues WHERE (tmplvarid = $tvid AND value LIKE '%$resid%')");
if ($stmt) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$data = explode('||' , $row['value']);
if (in_array($resid, $data)) {
$output .= $row ['value'];
$output .= "||"; }
} }
$output=str_replace('||',',',$output);
$output=str_replace("$resid,",'',$output);
$output=str_replace(',,','',$output);
$output = substr($output,'',-1);
return $output;
?>
The changes are exactly as Mark suggested. My ugly $output=str_replace code at the end simply changes the output 121||120|119|| to 121,119 for resource 120. There will be a better way of doing this.