I've managed to suppress the wrapping markup for a few blocks using

block--block--1.tpl.php region--banner.tpl.php

but now it's getting messy as I have several blocks which require no additional wrpaping markup so I would ideally like to do this in a theme function with a switch case...but can't find any example that works...

function front_preprocess_block(&$vars, $hook) {

$to_delete = array('block-block-4');

//if(in_array($vars['block']->delta , $to_delete)) {
//  $vars['template_files'][0] = 'block-empty'; 



I need to remove wrppaing DIV's for about 4 blocks onlys...ideas???


You can specify an additional variable in hook_preprocess_block() and check for that variable in block.tpl.php file, example:

function front_preprocess_block(&$vars, $hook) {
  $vars['must_be_removed'] = FALSE;
  if(/* CONDITION e.g. $vars['elements']['#block']->delta == 'MY_BLOCK_DELTA' */) {
    $vars['must_be_removed'] = TRUE;

and block.tpl.php file;

<?php if($must_be_removed): ?>
  <?php print $content ?>
<?php else: ?>
<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
  <h2<?php print $title_attributes; ?>><span><?php print $block->subject ?></span></h2>
<?php endif;?>
  <?php print render($title_suffix); ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php print $content ?>
<?php endif; ?>
  • Ohhh...so I can't stub out the markup just from a function but rather use the catch-all block.tpl.php and conditional tests...OK that works :) thank you kindly – Alex.Barylski Jan 28 '14 at 22:10
  • @Alex.Barylski I'm glad if I could help you.. – xurshid29 Jan 28 '14 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.