The variables I'm adding in my preprocessor function are not visible in the template for the unformatted view I've written. This seems to work fine if the template is formatted (the default).
That is, in template.php I set some variable $foo
in the preprocessor…
function themename_preprocess_views_view(&$vars) {
// Do view-specific preprocessing in here because of http://drupal.org/node/939462
if ( $vars['view']->name === "viewname" ) {
$vars['foo'] = 'bar'; // set $foo to be used in viewname templates
}
}
…such that I can use it in views-view--viewname.tpl.php, <?php echo $foo; ?>
. This works just fine.
However, $foo
is undefined in views-view-unformatted--viewname.tpl.php.
Why is this? How can I store the results of my preprocessing in a variable I can then use in the template for my unformatted view?
Doing the preprocessing in a function specific to the unformatted view doesn't work because
such a function,
themename_preprocess_views_view_unformatted__viewname()
, will not be called due to a bug, andworking around the bug by defining its behaviour in, or calling it from,
themename_preprocess_views_view()
doesn't work- as above, where I seem to make changes to
$vars
that should be accessible in all viewname view templates, - nor can it be repeated specifically for the unformatted view templates because there's nothing in
$vars
that can be used to discriminate the unformatted from the default view.
- as above, where I seem to make changes to
Any help?