Skip to content

Instantly share code, notes, and snippets.

@paulhhowells
Last active December 12, 2015 05:38
Show Gist options
  • Save paulhhowells/4723095 to your computer and use it in GitHub Desktop.
Save paulhhowells/4723095 to your computer and use it in GitHub Desktop.
Render Tabs — don’t print them if you don’t need ’em. Drupal 7.
add to template.php:
/*
* Implements template_preprocess_page
*/
function THEMENAME_preprocess_page(&$variables, $hook) {
// create $render_tabs & $show_render_tabs for page.tpl
$render_tabs = render($variables['tabs']);
$variables['render_tabs'] = $render_tabs;
$variables['show_render_tabs'] = strlen($render_tabs) ? TRUE : FALSE;
}
add to page.tpl:
<?php if ($show_render_tabs): ?>
<div class="tabs"><?php print $render_tabs; ?></div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment