function blockreference_autocomplete in Block reference 6
Same name and namespace in other branches
- 7.2 blockreference.module \blockreference_autocomplete()
- 7 blockreference.module \blockreference_autocomplete()
Retrieve a pipe delimited string of autocomplete suggestions
2 string references to 'blockreference_autocomplete'
- blockreference_menu in ./
blockreference.module - Implementation of hook_menu().
- blockreference_widget in ./
blockreference.module - Implementation of hook_widget().
File
- ./
blockreference.module, line 769 - Defines a field type for referencing a block from a node.
Code
function blockreference_autocomplete($field_name, $string = '') {
// If the request has a '/' in the search text, then the menu system will have
// split it into multiple arguments, recover the intended $string.
$args = func_get_args();
// Shift off the $field_name argument.
array_shift($args);
$string = implode('/', $args);
$fields = content_fields();
$field = $fields[$field_name];
$matches = array();
$references = _blockreference_potential_references($field, TRUE, $string);
foreach ($references as $rowbid => $rowname) {
$matches[_blockreference_item($field, $rowname) . ' [bid:' . $rowbid . ']'] = _blockreference_item($field, $rowname);
}
drupal_json($matches);
}