How to use template_preprocess_views_view to pass a variable to a views tpl file Since the case re-occurred to me for the second time recently, I decided to ask the question so to perhaps learn something.

In Views, the main display title (the one that usually gets rendered at the top of the view) is available in display output as $title but does not seem to be available in style output at all. Instead, the $title variable in style output means the name of a group if grouping is used.

What I want is to have that display title ('human name') available in any template as $display_title. So what I did was putting this code in my template.php:

function MYTHEME_preprocess_views_view(&amp;$variables){
  if($variables['name'] == 'studios' &amp;&amp; $variables['display_id'] == 'block'){
    $view = $variables['view'];
    $variables['display_title'] = $view-&gt;human_name;
  }
  dpm($variables);
}


...hoping to have the human title handy:
&lt;?php print $display_title; ?&gt;

...but no joy. What am I doing wrong?
As you would also know, a view has several templates, which can vary depending on the style, for example:


Display output: views-view.tpl.php
Style output: views-view-STYLE.tpl.php
Row style output: views-view-fields.tpl.php
Field content: views-view-field.tpl.php


etc.

Each of those templates has its own preprocess function. What you do in your code is only affecting the display output since you are preprocessing only the views-view.tpl.php (template_preprocess_views_view)

To find out which template files are available to your specific view, you can go to view edit page and under 'Advanced' section at the end of the column click on 'Theme: Information'. You will see which template files your view is using (in bold) and which template files you would use to override them.

The preprocess functions should be named after the template file, replacing the dashes with underscores. For example for views-view-STYLE.tpl.php would be template_preprocess_views_view_STYLE().