Hey All,

Im having some trouble getting a preprocess function to work. Im tweaking the garland theme while taking my first steps into drupal theming.
The goal is to theme a view i have build and add extra variables to it. So far Ive copied the "standard" views-view.tpl.php file info the garland directly and tweaked it slightly which worked fine.

Next on the list was getting the extra variables into the template. so i have setup a simple preprocess function in the template.php file of the garland theme to see if it worked. Sadly it didn't work. My function looks like this:

function garland_preprocess_views_view(&$variables) {
	$variables['test'] = "<p>test</p>";
}

Ive searched the net for other examples and i have tried like a dozen function name and nothing seems to work :S I'm also using a copy of the front end drupal book but the code used in the provided example is just about the same as my code. Ive also tried adding this function to my module with the module name instead of the theme name. no results. When i step through it with Xdebug it seems that the function do get "hit" but there not stepped into.

So i am out of options at this moment, im hoping you can point me in the right direction. Hope we can get this sorted out :D

Comments

Anonymous’s picture

Hey all,

This morning all of a sudden my preprocess function did work after presssing the "clear views cache" button (tools tab in views interface). Previously i just truncated the cache tables in my drupal database from my phpmyadmin....quess thats not the way to go about it :S

Anyway if anyone else has trouble with debugging/troubleshooting a view preprocess function make sure to wipe the cache frequently! Cheers!

ppblaauw’s picture

I have a similar issue with the views_slideshow_ddblock module where I use a preprocess function in the template.php file to add more variables and I use a tpl.php file to show content (overriding a tpl.php file defined in the module)

In the module I have a preprocess function to add variables and to add candidate template files.

When I empty cache its all fine, but when I adjust the view or the content the original tpl.php file is used and not the overriden tpl.php file (candidate template file ) in the theme.

Strange thing is when I copy all code from the preprocess function in the module to the theme, this preprocess function in the theme is always called, which sets the candidate template files, which are also used then.

Wiping the cache after updating a node which is used in the view is not an option I can use.
And copying the code from the preprocess function from the module to the theme is a solution.
But this should not be needed

Do you encounter the same issues?
When you say it looks like the function is called but not stepped into do you mean it uses some kind of cached version?
Do you still have the issues when you change something in the view or a node used in the view?

Thanks