You are here

function fieldblock_block_view in Field as Block 7

Implements hook_block_view(). Retrieves a field, identified by the block delta, from the static cache.

File

./fieldblock.module, line 163
Allow fields to be rendered in blocks.

Code

function fieldblock_block_view($delta = '') {
  $block = array();
  $fieldblocks_storage =& drupal_static(FIELDBLOCK_STORAGE_STATIC);
  if (isset($fieldblocks_storage[$delta])) {

    // If the field has a label, use it as block title and hide it on the
    // field itself.
    $block['subject'] = '';
    if (isset($fieldblocks_storage[$delta]['#label_display']) && $fieldblocks_storage[$delta]['#label_display'] != 'hidden') {
      $block['subject'] = $fieldblocks_storage[$delta]['#title'];
      $fieldblocks_storage[$delta]['#label_display'] = 'hidden';
    }
    $block['content'] = $fieldblocks_storage[$delta];
    $block['fieldblock_name'] = $fieldblocks_storage[$delta]['fieldblock_name'];
  }
  return $block;
}