0

When I give my module block a title it displays above my module block. How can I move this to display within my blocks template and not display above the template?

1

You can do this by overriding the block template:

create a template called block--block-name.tpl.php OR override all block templates by using block.tpl.php and move the code the prints the title into the content div:

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

  <div class="content"<?php print $content_attributes; ?>>
    <?php print render($title_prefix); ?>
      <?php if ($block->subject): ?>
       <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
      <?php endif;?>
    <?php print render($title_suffix); ?>
    <?php print $content ?>
  </div>
</div>
3
  • Can I use this block override template in the module though? So the module is self contained. – dibs Oct 6 '14 at 19:50
  • If you are using the blocks hook then you can add your template to the theme or module directory. – chadpeppers Oct 6 '14 at 20:17
  • I have a block template that I am adding via hook_theme_registry_alter() but still the title is before the block. Could you provide an example? – dibs Oct 6 '14 at 20:37

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.