Created
May 27, 2018 12:28
-
-
Save grvoyt/6144be5f0ed5de482e723f9980acc45b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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