<option value="[[+country]]">[[+country]]</option>
$children = $modx->resource->getMany('Children');<?php
$children = $modx->resource->getMany('Children');
if (!$children) { return false; }
// Check if there is a tpl set, if not return an error
$tpl = $modx->getOption('tpl', $scriptProperties, '');
if (!$tpl) { return 'No template given.'; }
foreach($children as $child) {
$out = array(
'country' => $child->getTVValue('country')
);
// ... and adding it to the output as placeholders in the chunk
$o .= $modx->getChunk($tpl, $out);
}
return $o;
$property_types = array();
foreach($search_results_unique as $filter_result){
if ( in_array($filter_result['property_type'], $property_types) ) {
continue;
}
$property_types[] = $filter_result['property_type'];
echo $filter_result['property_type'];
}<?php
$children = $modx->resource->getMany('Children');
if (!$children) { return false; }
// Check if there is a tpl set, if not return an error
$tpl = $modx->getOption('tpl', $scriptProperties, '');
if (!$tpl) { return 'No template given.'; }
$filter_countries = array();
foreach($children as $child) {
$country = $child->getTVValue('country');
if ( in_array($country, $filter_countries) ) {
continue;
}
$filter_countries[] = $country;
$out = array(
'country' => $country
);
$o .= $modx->getChunk($tpl, $out);
}
return $o;$o = '';
$tvId = 23; /* ID of the country TV */
$countries = array();
$result = array();
$docIds = $modx->getChildIds(38);
if (empty($docIds) {
return false;
}
// Check if there is a tpl set, if not return an error
$tpl = $modx->getOption('tpl', $scriptProperties, '');
if (!$tpl) { return 'No template given.'; }
$c = $modx->newQuery('modTemplateVarResource');
$c->select(array('value'));
$c->distinct(true);
$c->sortby('value'); /* (optional) */
$c->where(
array(
'tmplvarid' => $tvId,
'contentid:IN' => $docIds,
'value:!=' => '',
)
);
if ($c->prepare() && $c->stmt->execute()) {
$result = $c->stmt->fetchAll(PDO::FETCH_ASSOC);
}
$countries = array_map('current', $result);
foreach($countries as $country) {
$o .= $modx->getChunk($tpl, array('country' => $country));
}
$o = ''; $tvId = 23; /* ID of the country TV */ $countries = array(); $result = array(); $docIds = $modx->getChildIds(38); if (empty($docIds) { return false; } // Check if there is a tpl set, if not return an error $tpl = $modx->getOption('tpl', $scriptProperties, ''); if (!$tpl) { return 'No template given.'; } $c = $modx->newQuery('modTemplateVarResource'); $c->select(array('value')); $c->distinct(true); $c->sortby('value'); /* (optional) */ $c->where( array( 'tmplvarid' => $tvId, 'contentid:IN' => $docIds, 'value:!=' => '', ) ); if ($c->prepare() && $c->stmt->execute()) { $result = $c->stmt->fetchAll(PDO::FETCH_ASSOC); } $countries = array_map('current', $result); foreach($countries as $country) { $o .= $modx->getChunk($tpl, array('country' => $country)); }
$c->select(array('value'));$c->select(array('contentid'));Try changing this:
$c->select(array('value'));
To this:
$c->select(array('contentid'));
that holds the resource ID.