templates

When overriding templates: think of the children! (5)

The Drupal template override system is very intuitive: find the template you want to alter, copy it to your theme folder and adjust it. The handbook page on d.o about overriding themable output is even one of the most complete and appealing I've seen. So I was surprised when I wanted to override the core poll module's "Most recent poll" block, and found out it simply wasn't working. Try as I might the altered poll-results-block.tpl.php that was sitting in my custom theme folder wasn't being recognized, no matter how many times I cleared the registry or double-checked the paths and filenames. I had my Eureka moment want I came across this d.o issue about how themes can't use node-story.tpl.php without node.tpl.php. John Albin explains the history of this issue (and why it won't be fixed in Drupal 6) in comment #48.

The issue is fixed in Drupal 7 but just so you know in Drupal 6...

  • if you want to override poll-results-block.tpl.php you need to copy poll-results.tpl.php as well.
  • if you want to override comment-blog.tpl.php you need to copy comment.tpl.php as well.
  • if you want to create a Zen subtheme with region-sidebar-first.tpl.php you need to copy region.tpl.php as well.
Continue reading »
Syndicate content