开发者

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?


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.

  • place some debug code in the theme() function in includes/theme.inc to see what drupal_discover_template() returns for vairious template calls.

Can it find it? If not:

  • place some debug code in drupal_discover_template() to find out where Drupal thinks it no longer is a template.

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.


You need to rebuild the cache for the tpl.php file to be picked up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜