location filtern nach Ort anstatt PLZ

am 19.03.2014 - 12:08 Uhr in
Hallo,
ich habe location als Umkreissuche implementiert und er filtert mir die Ergebnisse korrekt nach PLZ. Nun möchte ich aber nicht nach PLZ sondern nach Ort filtern, d.h. ich gebe statt der PLZ den Ort in dem Input field ein.
Habt Ihr sowas schon implementiert bzw. wisst wie man das hin bekommt?
Danke und Grüße
naddoo
- Anmelden oder Registrieren um Kommentare zu schreiben
Ich habe eine Möglichkeit
am 26.03.2014 - 11:07 Uhr
Ich habe eine Möglichkeit gefunden die Umkreissuche über die Eingabe des Ortes zu implementieren http://agileadam.com/2012/03/proximity-by-city-or-zip-code-in-drupal-6-with-location-and-views/
Der Code der hier beschrieben ist, basiert auf Drupal 6 ich verwende aber Drupal 7. Ist dieser Code Abschnitt mit Drupal 7 kompatibel oder muss ich das noch anpassen
/**
* Implementation of hook_views_query_alter().
*/
function mymodule_views_query_alter(&$view, &$query) {
if ($view->name == 'stellenanzeigen') {
// Remove the exposed filter conditions from the WHERE clause (WHERE city = MyCityInput)
// and remove the corresponding args that were passed via the exposed filters
// This effectively turns the city and zip code exposed filters into just text fields
// that get used in mymodule_exposed_filter_proximity();
$city = $view->exposed_raw_input['city'];
$zip = $view->exposed_raw_input['zip'];
// Remove the city or zip arguments (from the exposed filters)
foreach ($query->where[0]['args'] as $key => $arg) {
if ($arg == $city || $arg == $zip) {
unset($query->where[0]['args'][$key]);
}
}
// Remove the corresponding WHERE clause additions
foreach ($query->where[0]['clauses'] as $key => $clause) {
if (strpos($clause, 'postal_code') !== FALSE || strpos($clause, 'city') !== FALSE) {
unset($query->where[0]['clauses'][$key]);
}
}
}
Hoffe Ihr könnt mir helfen.
Gruß
naddoo