phpviewdrupaldrupal-themingdrupal-themes

Custom Drupal theme template files not being used


I am trying to organize my theme folder, which has node theming overrides for dozens of views. Basically I have two different styles and I want them all to look the same, more or less.

Is there a way in template.php that I can do this? And what is the best way?

I tried this code in my theme's hook_preprocess_node function:

switch($vars['view']->name) {
 case 'taxonomy_term' :
   switch($vars['view']->current_display) {
     case 'page' :
       array_push($vars['template_files'], 'list-view');
     default :
       break;
   }
   break;
 default :
   break;
}

And when I look in theme developer, I can see the list-view.tpl.php file there, but its not actually using that file from my theme directory. What am I missing?


Solution

  • As you can see in theme() Drupal will only actually use a template if it exists according to drupal_discover_template().

    You should try to figure out if that is the case.

    Can it find it? If not:

    My gut-feeling says that it is due to subdirectories where the template files reside, but which you have not added to the template_files variable: views/lists/some_list.tpl.php is not the same as some_list.tpl.php.