function blockreference_autocomplete_value in Block reference 7
Same name and namespace in other branches
- 6 blockreference.module \blockreference_autocomplete_value()
- 7.2 blockreference.module \blockreference_autocomplete_value()
Value callback for a blockreference autocomplete element.
Replace the block bid with a block title.
1 string reference to 'blockreference_autocomplete_value'
- blockreference_field_widget_form in ./
blockreference.module - Implements hook_field_widget_form().
File
- ./
blockreference.module, line 392 - Defines a field type for referencing a block from a node.
Code
function blockreference_autocomplete_value($element, $input = FALSE, $form_state) {
if ($input === FALSE) {
// We're building the displayed 'default value': expand the raw bid into
// "block title [bid:n]".
$bid = $element['#default_value'];
if (!empty($bid)) {
$result = db_query('SELECT module, delta FROM {block} WHERE bid = :bid', array(
':bid' => $bid,
));
$block = $result
->fetchObject();
$info = module_invoke($block->module, 'block_info');
if (isset($info[$block->delta])) {
$value = $info[$block->delta]['info'];
$value .= ' [bid:' . $bid . ']';
return $value;
}
else {
// If you want these missing blocks to fail silently, without warning, set this variable to 0.
if (variable_get('blockreference_warn_about_missing_blocks', 1)) {
drupal_set_message(t("Delta %delta (bid @bid) is unknown in the block list coming from module %module, but it's still referenced in field %field.", array(
'@bid' => $bid,
'%delta' => $block->delta,
'%module' => $block->module,
'%field' => $element['#field_name'],
)), 'warning');
}
return '';
}
}
}
}