I have custom module with new block. When this block is displayed, the output is wrapped with html tags from block.tpl.php template:

<section id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

I would like to display only content without the wrapped html around. I can accomplish this by overriding the block.tpl.php file in the theme, however. This requires me to go into every possible theme and override the template file every time installing the module. How to avoid that? How to display only content of the custom block from custom module without overriding template file? Is there some attribute that i can set in the block render array like #theme_wrapper?:

$block['content'] = array(
               '#markup' => '<div>Hello World!</div>',
              // '#theme_wrappers' => array('attempt_to_override'),

I was thinking the 'theme_wrappers' attribute can be used, but i wasn't able. Thank you for any help

1 Answer 1


I don't actually think this is possible using a block; however, take a look at hook_block_view() and hook_block_view_alter().

Those MAY do what you want. They allow you to alter the contents of a block before it is displayed; however, it is likely that you'll still end up with the contents of the block 'inside' the template's block boiler plate.

Keep in mind that it's up to the theme to decide how blocks are styled so the theme markup boilerplate is there by design.

If you need to inject html into specific areas of the site / page you might need to do something differently.

In that case hook_page_build() or hook_page_alter() might be a better choice.

  • Thank You SMTF. I agree it is more of responsability of theme and not the module/block per say
    – latvian
    Nov 12, 2013 at 14:15

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.