function blockreference_formatter_get_block in Block reference 7
Helper function for theming normal block views, returns appropriate block.
4 calls to blockreference_formatter_get_block()
- theme_blockreference_formatter_default in ./
blockreference.module - Theme function for 'default' blockreference field formatter.
- theme_blockreference_formatter_plain in ./
blockreference.module - Theme function for 'plain' blockreference field formatter.
- theme_blockreference_formatter_title in ./
blockreference.module - Theme function for 'title' blockreference field formatter.
- theme_blockreference_formatter_without_title in ./
blockreference.module - Theme function for 'without_title' blockreference field formatter.
File
- ./
blockreference.module, line 726 - Defines a field type for referencing a block from a node.
Code
function blockreference_formatter_get_block($element) {
if (!empty($element['item']['bid']) && is_numeric($element['item']['bid'])) {
$bid = $element['item']['bid'];
$query = db_select('block', 'b');
$result = $query
->fields('b')
->condition('b.bid', $bid)
->addTag('block_load')
->addTag('translatable')
->execute();
$blocks = $result
->fetchAllAssoc('bid');
if (isset($blocks[$bid])) {
if ($element['field']['settings']['respect_visibility']) {
// Set status to 1 manually, so block.module actually evaluates visibility.
$blocks[$bid]->status = 1;
// Allow block.module and other modules to modify the block list.
drupal_alter('block_list', $blocks);
}
if (isset($blocks[$bid])) {
return $blocks[$bid];
}
}
}
return FALSE;
}