Jump to:
| Project: | Zen |
| Version: | 7.x-3.x-dev |
| Component: | PHP code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
Running Drupal 6.4 with zen and a custom subtheme.
Site layout is as follows:
/var/www/ -- Drupal Root
/var/www/sites/all/themes/zen/zen/ -- Zen theme folder
/var/www/sites/default/themes/custom/ -- Custom subtheme folder
Created a custom node type called news_filter and created a single node of that type.
Created a theme template file called node-news_filter.tpl.php in my subtheme folder. Then restarted the webserver, cleared the cache via admin/settings/performance page, and refreshed the page view of the node.
The template did not take effect.
Moved the theme template file to the Zen theme folder and restarted/cleared/refreshed as above.
The template took effect.
Moved the theme template file back to the custom folder, cleared cache, stopped the webserver, and restarted it under strace, then refreshed the page view.
According to the trace file, the following file locations were searched, in order:
sites/all/themes/zen/zen/node-news_filter.tpl.php
sites/all/modules/og/node-news_filter.tpl.php
sites/all/modules/advanced_forum/themes/advforum/node-news_filter.tpl.php
modules/node/node-news_filter.tpl.php
sites/all/themes/zen/zen/node.tpl.php
According to the Zen documentation, the proper way to override theme templates is to create template files in your subtheme folder. This clearly contradicts the observed behavior.
So is the documentation wrong, or is the code wrong?
Do I have to edit my subtheme's template.php?
Comments
#1
Make sure the original node.tpl.php is also in your Custom folder. I believe it also has to be in the same folder as your node-news_filter.tpl.php.
#2
Re: newkid85
Your belief contradicts both the documentation and my observations.
Nevertheless, I will try your suggestion:
The template file did not take effect.
Perhaps you meant that the template file needs to be in the same folder as the *original* node.tpl.php file, which is to say, in the zen theme folder (rather than the subtheme folder). This agrees with my observations but contradicts the zen documentation.
I ask again, is the code wrong or is the documentation wrong?
#3
Marking this as a bug, though I'm unsure where the bug lies.
#4
The documentation says it explicitly actually.
Suggestions only work when it is placed in the same directory as the base template. In other words, trying to get comment-blog.tpl.php to work, comment.tpl.php also needs to exist inside your theme and in the same directory.
#5
I missed this too.
Thanks for the great work with zen.
I was having the above problem and after reading this I just made sure to clean up my folders.
../sites/all/themes/zen has the parent theme
../sites/www.example.com/zen_example/ <--has the files I need and those as noted above (node.tpl.php etc) so I can then add
node-image.tpl.php etc so I can overwrite a bunch of layout needs.
../sites/www.example2.com/zen_example2/
#6
Aha! I was wondering why getting this to work was so inconsistent across the various sites I've used Zen on. I now see that the times it wasn't working, it must have been because I didn't have a node.tpl.php in my subtheme directory.
After coming across this problem again recently, I decided to figure it out once and for all and found this issue. I can confirm that, after copying node.tpl.php into my subtheme's directory, node-[node_type].tpl.php automagically started working too.
#7
I found the same requirement for block templates.
I find it a bit unintuitive, frustrating (I lost an hour on it) and considering the magic of phptemplate suggestions otherwise, a bit inefficient.
If the behavior could be cleaned up to honor those suggestions without requiring redundant copy&paste of the base templates, that would be an improvement.
Seeing as it is documented or documentable, we can call this a feature request I guess.
#8
It is very unintuitive, but according to the documentation, it looks like it's an issue with Drupal 6 itself, not with Zen.
#9
Fixing it is hairy. See the core issue: #279573: Themes can't use node-story.tpl.php without node.tpl.php
The final word on this issue (from Zen's pov) is what mistresskim said above: http://drupal.org/node/311201#comment-1021697
Sorry guys. I agree its unintuitive. But its the way core works. (for now)
#10
Looks like it's fixed with Drupal 6.7:
-> http://drupal.org/node/345462
"#333060 by neclimdul, merlinofchaos, dvessel: child themes did not inherit
patterns correctly, so more specific template files are not detected"
There is also:
"#258089 by JohnAlbin, Arancaytar, merlinofchaos: themes cannot have
a preprocess function without a corresponding .tpl.php file"
Szy.
#11
Um… no, it’s not fixed yet. #279573: Themes can't use node-story.tpl.php without node.tpl.php
#13
Postponed is a more accurate status. Sounds like you will fix, but it's awaiting another issue. I referenced this in the other issue.
#14
Has been any advance on this issue?
I've tried this patch [1] but with no effect. Also I've moved the sub theme directory to the Zen theme dir, with no efect either.
Is there a Q&D workaround? I'm really stuck with this... Maybe some dirty hardcoding until this issue is solved. But I've no clue where to start.
[1] http://drupal.org/node/279573#comment-993105
#15
JohnAlbin commented at #279573: Themes can't use node-story.tpl.php without node.tpl.php, where the relevant issue is #678714: Unify use of theme hook / template suggestions, fix clobbering problems, and improve suggestion discovery performance, so this sound like a won't fix, but we all love d7 ;-)
#16
I was experiencing the same problem using Drupal 7 with a Zen sub-theme.
Two important things.
1.) The node.tpl.php file is not needed in the sub-theme directory
2.) The name of the node type specific theme override file has the following format node--[node type].tpl.php !!!!! TWO DASHES NOT ONE !!!!!!
see http://diggit.drupalextras.com/node/72624/related_links
#17
@ap - Thanks! That works perfectly.
Tim