I have a Region in the theme called header-top. As you may notice this region has a dash in the name instead of an underscore.

This theme is a sub-theme of a master theme called Framework. I wanted to apply a certain template file to blocks in that region, so according to Drupal 7 Theme Hook Suggestions page I've created a template file called block--header-top.tpl.php and cleared the cache. After re-loading the page a few times, I inspect the HTML to see if this particular template file is being applied, but all evidence suggests that it's still using block.tpl.php. I've tried using template_preprocess_block and dpm-ing out the $variables and in there I see an array theme_hook_suggestions which has the following values: array(block__header-top, block__block, block__block__21). I've checked the existing template files and there's no template file named block--block.tpl.php or block--block--21.tpl.php. I've even tried to swap the dash with an underscore to be block--header_top.tpl.php but still no luck.

Finally I've switched the region name to become header_top and the renamed template block--header_top.tpl.php suddenly starts to take effect.

I'm wondering is there a certain naming convention for regions with dashes in the name? If so what would be the ways to try and find out what exactly the template name for this region should be? I'd like to not resort to renaming the region, as that may have a knock-on effect on modules and other template files which I may miss and mess up the production website.

  • Did you clear the caches after changing the dash to an underscore? That method should work just fine
    – Clive
    Jun 17, 2013 at 12:35
  • I've cleared the cache on every step. The dash in the region name just doesn't seem to work.
    – Beebee
    Jun 17, 2013 at 12:37
  • The dash wouldn't but the underscore does (in a standard install anyway). Do you have any contrib modules or an over-zealous theme installed that might be affecting it?
    – Clive
    Jun 17, 2013 at 12:39
  • No as far as I know there aren't any. When I had the template file block--header-top.tpl.php it had HEADER TOP at the top of the file. Also I put TEST on top of block.tpl.php and before I renamed the region, I could only see TEST but after the region is renamed I see HEADER TOP being output. So the theming engine is definitely falling back to block.tpl.php in my theme folder. /scratches head
    – Beebee
    Jun 17, 2013 at 12:42
  • 1
    Yeah you need to use underscores, per the docs you linked to: "An example of a region-specific template would be "block--sidebar_first.tpl.php"."
    – Clive
    Jun 17, 2013 at 12:52

1 Answer 1


Per the Theme suggestion docs you linked to the format for region-specific block templates go like this:

An example of a region-specific template would be "block--sidebar_first.tpl.php"

It looks like Drupal flips _ and - in theme suggestions so




(I knew it replaced _ with - but I didn't know it was the other way round too; there may be more to it than that).

  • 1
    It looks like if your region name has an underscore, then it doesn't seem to matter if you use a dash or an underscore in the template name they both work. However if your region has a dash, then it doesn't seem to matter what you use... the template doesn't get picked up.
    – Beebee
    Jun 17, 2013 at 13:04

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.