Dies ist ein kleines Module was der OG Gruppensuche eine Autovervollständigung hinzufügt.
OG_Autocomplete.module
<?php
/**
* Implementation of hook_menu()
*/
function og_autocomplete_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'og_autocomplete/js',
'title' => t('Og_autoComp Menu'),
'callback' => 'og_autocomplete_js',
'access' => TRUE
);
}
return $items;
}
function og_autocomplete_js($string = '') {
drupal_set_message('test'. $string);
$result = db_query("SELECT * FROM {node} WHERE status = 1 AND type = 'gruppe' LOWER(title) LIKE LOWER('%%%s%%')", $string);
$matches = array();
while ($item = db_fetch_object($result)) {
dsm($item);
$matches[$item->title] = check_plain($item->title);
}
print drupal_to_js($matches);
exit();
}
?>
Das Module macht an sich noch nichts, denn es muss noch die Form verändert werden:
dazu einfach
<?php
function phptemplate_views_filters($form) {
if ($form['#view_name'] == 'og') {
$form['filter0']['#autocomplete_path'] = 'og_autocomplete/js';
}
return theme_views_filters ($form);
}
?>
Ins Theme einfügen und fertig und noch in der SQL Query type = '' verändern. Fertig
Add new comment