Beware of long View names.

I was debugging a Views block the other day and couldn't figure out why it wasn't hitting my block tpl. Pretty scary why it wasn't..

but first some background.
 
the view:     product_category_reviews
display id:  block_1
 
Standard Drupal block theming will pick up block.tpl.php unless it finds something earlier in the $template_files that it can use.
 
In D5 our tpl was:             block-views-product_categories_reviews.tpl.php
 
in D6, we need to include display id in this so tpl would become:               block-views-product_categories_reviews -block_1.tpl.php
 
BUT.. this wasn't being hit...
 
when I put a breakpoint in block.tpl.php and looked at the $template_files var, the array was:
 
[0]          block-content_bottom  (this is the region the block is in)
[1]          block-views
[2]          block-views-ba843477361f490ca5c9e42548f0127d
 
which means Drupal is looking for a tpl named: block-views-ba843477361f490ca5c9e42548f0127d.tpl.php
 
and again.. what the hell??
 
turns out that Views (lord know why it doesn't just complain about this) has a view name that with the display id on it exceeds 32 characters.. it hashes the name for internal use for things like tpls.
 
since "product_categories_reviews -block_1" exceeds 32 characters...
 
I changed the view name to our_reviews and changed the tpl to block-views-our_reviews-block_1.tpl.php and sure enough.. we're good to go!!
Tags: