1

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'; 
//}

print_r($vars);

}

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

1 Answer 1

1

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) {
  //dpm($vars);
  $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 ?>
  </div>
</div>
<?php endif; ?>
2
  • 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 Jan 28, 2014 at 22:10
  • @Alex.Barylski I'm glad if I could help you..
    – xurshid29
    Jan 28, 2014 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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