I was quite happy to see that the site footer and associated items were moved to the block interface in 4.7, and also that we gained the ability to put PHP into these entities. Yay!

However, this now presents a new issue - now that the footer (etc.) is a bona-fide block, it is displayed with all the block 'adornments' (i.e. the block title) for the theme in use. This makes it less than pretty for something like a simple copyright message in the page footer. (I'm using pushbutton, which seems to be the only 4.7 theme that displays a header and footer). So I'd like to open an enhancement to allow a block configuration item to 'just display the block contents' without the title and theme wrappers that would normally be put on a sidebar block. It would also be nice of course if more themes displayed a header/footer, but I'll save that for another day.

I also couldn't find a project for the pushbutton theme to file this under, and it's kind of in that grey area between core and theme, so I'm putting it under the block.module, since it was changes in that module which exposed the issue. Please feel free to redirect to the appropriate (?) place...

CommentFileSizeAuthor
#4 theme_block_region.patch1.87 KBsvemir

Comments

Moxide’s picture

Hello,

I'm not a Drupal specialist, but what you are requesting can easily be done by editing the file "block.tpl.php" of your theme.
Simply delete : <h2 class="title"><?php print $block->subject; ?></h2> and all block titles will disappear.

If you want to hide the footer title only, replace the line above with:
<?php if($block->region<>'footer') print "<h2 class=\"title\">{$block->subject}</h2>"; ?>

macgirvin’s picture

Thanks - I finally tracked through it all and was trying to do something like this from one level upstairs in the theme engine and splitting off the block template into two branches i.e. footer-block.tpl.php, but wasn't having much luck.

nedjo’s picture

If you come up with a good general solution, please post a patch on the core PHPTemplate themes.

svemir’s picture

Status: Active » Needs review
StatusFileSize
new1.87 KB

Here is a patch that allows the templating engine to use a different sub-template for a block based on its region.

theme.inc->theme_blocks() needs to pass the region to theme_block(), which adds the region to the array it passes to the engine. Engine optionally uses (for example) footer_block.tpl.php instead of block.tpl.php (if it exists.) It seems a minor change in the code to me, but I did not follow the development of the current themeing system.

Until this or some other such patch is approved, you can always style footer blocks differently from other blocks. E.g. to hide the block title in pushbutton footer, add this into the pushbutton's style:

#footer-message .block .title h3 {
  display: none;
}
Crell’s picture

While I can see a reason to disable block titles in headers and footers, I can see a reason to disable them in sidebars, too. However, it should be selective.

Why not add a "show block title" checkbox to each block's config page? If the admin wants a block to have a title, let it. If not, don't give it one. Where it's placed on the page shouldn't make a difference.

macgirvin’s picture

Crell's suggestion here is actually what I was asking for in the original bug report (configuration of whether or not to display the block title or just the block contents for any given block, regardless of location) - but I don't know that it's easily doable in the 4.7 time frame. The theme hack is a quick solution for now.

If we are able to configure whether or not to display the block title, it gives us a nice clean and simple interface for arbitrary HTML/PHP snippets that can appear anywhere on the page. I've seen several issues requesting this ability. It's so close, but not quite there. Think of it as poor man's modules. The currently mandatory title display seems to be the only thing standing in the way of blowing this opportunity wide open.

svemir’s picture

Status: Needs review » Active

Please ignore the patch I submitted previously. It is totally useless. Blocks already "know" their region, so it is possible to have all the logic you need in the template itself, as demonstrated in one of the comments above. Even if some configuration option for blocks is added in the future, the logic which will check the value of that option will be in the template itself, just as it is demostrated above. Just, instead of checking the region it will check something else.

webchick’s picture

Title: Block title in footer » Remove block title in footer
Project: Drupal core » Documentation
Component: block.module » Admin Guide

Moving to documentation project... for possible inclusion in theme snippets?

Crell’s picture

Status: Active » Fixed

Drupal 5 now offers this functionality.

Anonymous’s picture

Status: Fixed » Closed (fixed)