0

I have a region on my home page called home_area_1. It contains several blocks. I want those blocks to be formatted in the same way, so I created a template called block--home-area-1.tpl.php. It is formatting those blocks correctly, but it's also being applied to blocks in other regions on the home page.

What am I doing wrong? I only want the blocks in this particular region to use this template.

I'm on Drupal 7.35, and am fairly new at this.

1

As stated in Drupal 7 Template (Theme Hook) Suggestions, it suggests the file name structure to be like block--sidebar_first.tpl.php.

==EDITED==

In my themename.info file I declared

regions[sidebar_first] = First Sidebar

Copied the core block.tpl.php file, renamed it to block--sidebar_first.tpl.php, added "BLOCK NAKO" text.

Then I Flushed Caches. The image below is the result.

enter image description here

As you can see the footer region blocks doesn't have the override that I only set for blocks within the sidebar first region.

  • I'm sorry, I don't know what that means. My template IS named using that format - block--regionName.tpl.php. – EmmyS Apr 6 '15 at 14:38
  • Even changing the dashes to underscores doesn't help - it's still being applied to blocks in other regions. – EmmyS Apr 6 '15 at 14:47
  • I meant that based on Drupal's template naming suggestions. since your region is 'home_area_1', the file name you used w/c is 'block--home-area-1.tpl.php' isn't right. It should be 'block--home_area_1.tpl.php' so that it would only format blocks in that region. – Leolando Tan Apr 6 '15 at 14:48
  • Have you tried flushing the cache? – Leolando Tan Apr 6 '15 at 14:53
  • I also did an edit to my answer. You're welcome. Glad it's all working. – Leolando Tan Apr 6 '15 at 15:00

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.