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.
block--header-top.tpl.php
it hadHEADER TOP
at the top of the file. Also I putTEST
on top ofblock.tpl.php
and before I renamed the region, I could only seeTEST
but after the region is renamed I seeHEADER TOP
being output. So the theming engine is definitely falling back toblock.tpl.php
in my theme folder. /scratches head