You are here

function theme_blockreference_formatter_title in Block reference 6

Same name and namespace in other branches
  1. 7.2 blockreference.module \theme_blockreference_formatter_title()
  2. 7 blockreference.module \theme_blockreference_formatter_title()

Theme function for 'title' blockreference field formatter.

File

./blockreference.module, line 319
Defines a field type for referencing a block from a node.

Code

function theme_blockreference_formatter_title($element) {
  $field_name = $element['#field_name'];
  $field = content_fields($field_name);
  $output = '';
  if (!empty($element['#item']['bid']) && is_numeric($element['#item']['bid'])) {
    $block = db_fetch_object(db_query(db_rewrite_sql("SELECT * FROM {blocks} WHERE bid = " . $element['#item']['bid'], 'blocks', 'bid')));
    $block->enabled = TRUE;
    $block->status = TRUE;
    $block->page_match = TRUE;
    $block_view = module_invoke($block->module, 'block', 'view', $block->delta);
    $subject = $block->title ? $block->title : $block_view['subject'];
    if ($block_view['content']) {
      $output = check_plain($subject);
    }
  }
  return $output;
}