views:

195

answers:

2

I've created a Block using a View and would like to add some information to it that cannot be obtained from the View itself. I need to write a small function that queries for some extra data.

I thought of putting this function in the MYTHEME_preprocess_node but when I put a simple $variables['test'] = 'test' and then do a print $test in one of the .tpl files that outputs the Block's content, nothing shows.

Am I on the right track?

A: 

The thing is that the preprocess_ function is tied to a specific template. So preprocess page will generate variables available in the page.tpl.php while preprocess_node will do it for the node.tpl.php. So you can either use MYTHEME_preprocess which should run for all the templates or use the MYTHEME_preprocess_templatename. I'm not sure exactly how the naming schemes are vs the template naming system. However the devel module has an option that allows you to see which preprocess functions are run on the page you view, which should be able to help you out to figure out what to call the preprocess function if you have troubles getting it to work.

googletorp
A: 

You could also use the Theme Info option in the Views Interface to identify the templates pulled in by Views. I'm not sure whether you can write preproccess functions for those templates, but you can create View-specific override templates in your Theme directory by following the name schemes offered in Theme Info.

That template could include SQL queries.

Grayside
This is what I've done. Not very pretty but it works. Thanks
stef