function blockreference_autocomplete in Block reference 7
Same name and namespace in other branches
- 6 blockreference.module \blockreference_autocomplete()
- 7.2 blockreference.module \blockreference_autocomplete()
Menu callback for the autocomplete results.
4 string references to 'blockreference_autocomplete'
- blockreference_content_migrate_instance_alter in ./
blockreference.module - Implements hook_content_migrate_instance_alter().
- blockreference_field_widget_form in ./
blockreference.module - Implements hook_field_widget_form().
- blockreference_field_widget_settings_form in ./
blockreference.module - Implements hook_field_widget_settings_form().
- blockreference_menu in ./
blockreference.module - Implements hook_menu().
File
- ./
blockreference.module, line 652 - Defines a field type for referencing a block from a node.
Code
function blockreference_autocomplete($entity_type, $field_name, $current_bid, $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 $entity_type argument.
array_shift($args);
// Shift off the $field_name argument.
array_shift($args);
// Shift off the $current_bid argument.
array_shift($args);
$string = implode('/', $args);
$field = field_info_field($field_name);
$matches = array();
$blocks = _blockreference_potential_references($field, array(
$current_bid,
), TRUE, $string);
foreach ($blocks as $bid => $block) {
$matches[_blockreference_item($field, $block) . ' [bid:' . $bid . ']'] = _blockreference_item($field, $block);
}
drupal_json_output($matches);
}