function getlocations_blocks_city_get in Get Locations 7
Same name and namespace in other branches
- 7.2 modules/getlocations_blocks/getlocations_blocks.module \getlocations_blocks_city_get()
Return value
array Provides an array for a city dropdown
1 call to getlocations_blocks_city_get()
- getlocations_blocks_city_form in modules/
getlocations_blocks/ getlocations_blocks.module
File
- modules/
getlocations_blocks/ getlocations_blocks.module, line 429 - getlocations_blocks.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_blocks_city_get() {
$settings = getlocations_blocks_get_var();
$matches = array(
'' => t('Select a city'),
);
$query = db_select('getlocations_fields', 'f');
$query
->fields('f', array(
'city',
));
if ($settings['city_filter'] && $settings['city_filter'] == 'field_name' && $settings['city_filter_fieldname']) {
$query
->join('getlocations_fields_entities', 'e', 'f.glid=e.glid');
$query
->condition('e.field_name', $settings['city_filter_fieldname']);
}
elseif ($settings['city_filter'] && $settings['city_filter'] == 'bundle' && $settings['city_filter_bundle']) {
$query
->join('getlocations_fields_entities', 'e', 'f.glid=e.glid');
$query
->join('field_config_instance', 'i', 'e.field_name=i.field_name');
$query
->condition('i.bundle', $settings['city_filter_bundle']);
}
$result = $query
->execute();
foreach ($result as $row) {
if ($row->city) {
$matches[$row->city] = getlocations_apoclean($row->city);
}
}
ksort($matches);
return $matches;
}