function ds_render_block_field in Display Suite 7.2
Same name and namespace in other branches
- 7 ds.module \ds_render_block_field()
Render a block field.
1 call to ds_render_block_field()
- ds_get_field_value in ./
ds.module - Get the value for a Display Suite field.
File
- ./
ds.module, line 927 - Display Suite core functions.
Code
function ds_render_block_field($field) {
global $theme_key;
list($module, $delta) = explode('|', $field['properties']['block']);
// Load the block
$result = db_select('block', 'b')
->fields('b')
->condition('b.theme', $theme_key)
->condition('b.module', $module)
->condition('b.delta', $delta)
->addTag('block_load')
->addTag('translatable')
->execute();
$block_info = $result
->fetchAllAssoc('bid');
// Enable the block
if ($block_info[key($block_info)]->status == 0) {
$block_info[key($block_info)]->status = 1;
}
// Process the block if it respects visibility settings
if (isset($field['properties']['block_visibility']) && $field['properties']['block_visibility']) {
drupal_alter('block_list', $block_info);
}
// Simulate _block_load_blocks() return, containing only our block.
$block = array_shift($block_info);
// Render the block field
if (isset($block)) {
$key = $module . '_' . $delta;
if (module_exists('block')) {
$region_blocks = _block_render_blocks(array(
$key => $block,
));
switch ($field['properties']['block_render']) {
case DS_BLOCK_TEMPLATE:
$renderable_block = _block_get_renderable_array($region_blocks);
return drupal_render($renderable_block);
break;
case DS_BLOCK_TITLE_CONTENT:
if (isset($block->subject) && isset($block->content) && $block->content) {
return '<h2 class="block-title">' . $block->subject . '</h2>' . drupal_render($block->content);
}
break;
case DS_BLOCK_CONTENT:
if (isset($block->content) && $block->content) {
return drupal_render($block->content);
}
break;
}
}
}
}