views:

367

answers:

1

Anyone have any ideas on how I might embed a region into a view .tpl.php file?

I accomplish it easily enough in a node .tpl.php by adding something like this to theme_preproces_node():

$vars['promos'] = theme('blocks', 'promos');

No problem at all. However, there obviously isn't a theme_preprocess_view() function, and I get memory errors when I try to add the same snippet to theme_preprocess().

Fatal error: Allowed memory size of 104857600 bytes exhausted (tried to allocate 523800 bytes) in /Users/cpharmston/Sites/Projects/Threespot/neh01/includes/database.mysqli.inc on line 42

I'm stumped. Any ideas?

Thanks!

+3  A: 

'Quick and dirty' way: You could just put the theme('blocks', [region_name]) call directly into the views .tpl.php file.

While the preprocess functions aim at a better separation of 'business' logic vs. 'display' logic, they are not required in any way, so you can still put custom code in a .tpl.php file any way you like.

'Proper' way: There are preprocess functions for views, just more than one. Take a look at the theme.inc file of the views module. There you'll find different preprocess functions for the different templates possibly used by a view (e.g. 'unformatted' vs. 'table' vs. 'list', etc.). You just need to find the one relevant for the view template you want to inject the new variable.

Henrik Opel
File this one under the "DOH!" category. I was so deep into separating business and display logic that I overlooked the obvious. Thanks for the help :)
cpharmston
+1 Showing the proper Drupal way
googletorp