Skip to content

Instantly share code, notes, and snippets.

@grvoyt
Created May 27, 2018 12:28
Show Gist options
  • Save grvoyt/6144be5f0ed5de482e723f9980acc45b to your computer and use it in GitHub Desktop.
Save grvoyt/6144be5f0ed5de482e723f9980acc45b to your computer and use it in GitHub Desktop.
<?php
$output = array();
$q = $modx->newQuery('modTemplateVarResource');
$q->select('DISTINCT(`modTemplateVarResource`.`value`)');
$q->innerJoin('modTemplateVar', 'tv', "tv.id = modTemplateVarResource.tmplvarid");
$q->innerJoin('modResource', 'res', 'res.id=modTemplateVarResource.contentid');
$q->where(array(
'tv.name' => 'category',
'res.context_key' => $modx->resource->context_key,
'res.parent' => 17
)
);
$res = '';
if ($q->prepare() && $q->stmt->execute()) {
while ($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) {
$output[] = $row['value'];
$res .= '<option value="'.$row['value'].'">'.$row['value'].'</option>';
}
}
return $res;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment