function recipe_autocomplete_page in Recipe 7
Same name and namespace in other branches
- 5 recipe.module \recipe_autocomplete_page()
- 6 recipe.module \recipe_autocomplete_page()
- 7.2 recipe.admin.inc \recipe_autocomplete_page()
Page callback: Outputs JSON for ingredient autocomplete suggestions.
1 string reference to 'recipe_autocomplete_page'
- recipe_menu in ./
recipe.module - Implements hook_menu().
File
- ./
recipe.module, line 1303 - Contains functions for Recipe node CRUD and display.
Code
function recipe_autocomplete_page($string = "", $limit = 10) {
$matches = array();
$query = db_select('recipe_ingredient', 'ri')
->fields('ri', array(
'name',
))
->where('LOWER(name) LIKE :name', array(
':name' => strtolower($string) . '%',
))
->orderBy('name', 'ASC')
->range(0, $limit);
$result = $query
->execute();
foreach ($result as $record) {
$matches[$record->name] = check_plain($record->name);
}
drupal_json_output($matches);
exit;
}