Tabs out of referenced blocks (block reference field template)
<div class="f-<?php print str_replace('_','-',str_replace('field_','',$element['#field_name'])); ?> <?php print $classes; ?>"<?php print $attributes; ?>>
<?php if (!$label_hidden): ?>
<div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>: </div>
<?php endif; ?>
<div class="field-items"<?php print $content_attributes; ?>>
<?php
$output = '';
$titles = '';
$i = -1;
$bids = field_get_items('bean', $element['#object'], 'field_recent_tabs');
foreach ($bids as $bid) {
$i++;
//print $bid['bid'];
$block_info = db_query('SELECT module, delta FROM {block} WHERE bid=:bid LIMIT 0, 1', array(':bid' => $bid['bid']))->fetchAssoc();
$block = block_load($block_info['module'],$block_info['delta']);
$render_array = _block_get_renderable_array(_block_render_blocks(array($block)));
reset($render_array);
// print both titles;
$title = $render_array[key($render_array)]['#block']->subject;
$id = preg_replace('/\s*/', '', strtolower($title));
$active = '';
$in = '';
if ($i == 0) {
$active = ' active';
$in = ' in';
}
$titles .= '<li class="' . $active . '"><a href="#' . $id . '" data-toggle="tab">' . $title .'</a></li>';
// remove title
$render_array[key($render_array)]['#block']->subject = '';
$output .= '<div class="tab-pane fade' . $active . $in . '" id="' . $id . '">' . render($render_array) . '</div>';
}
print '<ul class="nav nav-tabs">' . $titles . '</ul>';
print '<div class="tab-content">' . $output . '</div>';
?>
</div>
</div>