Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
theme system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
29 Oct 2010 at 23:06 UTC
Updated:
3 Jan 2014 at 02:04 UTC
Jump to comment: Most recent
- Downloaded Drupal 7 Dev.
//I have to have my theme name in place of phptemplate else it dose not work
function phptemplate_preprocess_page(&$vars)
{
echo '<pre>';
print_r($vars['theme_hook_suggestions']);
echo '</pre>';
}
'theme_hook_suggestions' is the replacement to 'template_files'.
According to this presentation http://www.slideshare.net/pingv/grok-drupal-7-theming?from=ss_embed slide 82 we only have one '--' but the currently we are getting the following.
This is the result.
Array
(
[0] => page__node
[1] => page__node__%
[2] => page__node__17
)
The theme files.
page.tpl.php
page--node.tpl.php
page--node--1.tpl.php
Do override but not according to the presentation.
WE SHOULD have the following result.
Array
(
[0] => page__node
[1] => page__node_%
[2] => page__node_17
)
The theme files.
page.tpl.php
page--node.tpl.php
page--node-1.tpl.php
Which is not the case.
Comments
Comment #1
EvanDonovan commentedMoving to proper component & demoting priority. At most, this is major. Perhaps this is the intended behavior, though, in which case the presentation is simply out-of-date. People who worked on the theme system for D7 will have to give feedback.
Comment #2
EvanDonovan commentedI think that this bug is probably "normal" priority, but want to wait for the relevant people to make that determination.
Comment #3
droplet commentedsimilar issues: #821446: Need tests for region-specific overrides of region.tpl.php
for me I always think it is a critical issue. I don't understand why Drupal sometimes ship a broken system to end user.(It's issue can be affect to ALL drupal 7 themes)
Comment #4
EvanDonovan commented@droplet: Thanks for pointing to the other issue. As far as priority goes, please read Priority levels of issues, especially the definition of critical: "Critical bugs either render a system unusable...or expose security vulnerabilities."
This bug, by definition, does not render Drupal unusable as a whole; I don't even think it meets the criteria for a major bug, since it only affects the theme system, and it does so by changing the system's expected behavior, not by making it impossible to override templates at all. It could be fixed in a point release, if necessary; it doesn't need to block release of 7.0.
That said, I have tagged it as a regression, and with "needs themer review" in the hopes that will attract the right people to review it.
Comment #5
eric_a commentedPage 82 of the presentation says:
@jucallme: I'm not sure which part of the presentation suggests anything else than the following sources. I don't see any examples in the presentation using the page hook, as in your post. Do you think there is a problem with http://api.drupal.org/api/function/theme_get_suggestions/7 ?
From the API Docs (http://api.drupal.org/api/function/theme/7):
In #821446: Need tests for region-specific overrides of region.tpl.php Effulgentsia writes:
Comment #6
EvanDonovan commented@Eric_A: So what is the difference between delimiters and words? This sounds to me like it is actually a documentation problem, where the documentation on changes from D6 should be made clearer.
Comment #7
eric_a commentedThe text from http://drupal.org/update/theme/6/7#template_files_double_hyphen might benefit from an example with multiple occurences of the double hyphen.
The system strips double hyphens until it finds a hook implementation. It strips at delimiters and checks, it does not at words.
From theme():
Comment #8
EvanDonovan commentedChanging this to a documentation task, then. I am sure that I am not the only person who finds this confusing. An example with the double hyphen (probably with "node--long-content-type-name.tpl.php", to stick with the current example given) would be helpful.
Comment #9
roam2345 commented@Eric_A Im not to clued up on the Drupal Core functions.. I'm more of a themer. But from all the documentation and podcasts (Lullabot voices also has more around this Drupal 7 theming I think) I have herd and read, this is not working as it has been broad casted and talked about.
D7 now uses this 'theme_hook_suggestions' to figure out what pages are eligible for over riding templates. If I out put that 'theme_hook_suggestions' I get this on a page node. This is the default behavior.
Array
(
[0] => page__node
[1] => page__node__%
[2] => page__node__17
)
And can override this page with page--node--17.tpl.php. According to all the documentation, podcasts covering this matter that I have seen, this is incorrect. We should be overriding the template with page--node-17.tpl.php. That means the out put of 'theme_hook_suggestions' should be
Array
(
[0] => page__node
[1] => page__node_%
[2] => page__node_17
)
As I say I'm not to clued up on the drupal functions, but the one place I think 'theme_hook_suggestions' this is not what I'm expecting.
With regards to the level of the bug you guys know best, but from a architectural point of view this is very high, even though on the functional scale this is the opposite.
my 2 cents, hope it helps a little.
Comment #10
eric_a commentedIf your comment is specific to the node and node/% router paths, then there may be more to it, because the "node/%" path is very different from the "node" path.
Consider these hooks:
page__node__1
page__node__1__html1
page__node_1
page__node_1__html1
They could mean different things. The integers would be just types in the first 3 hooks, not node ID's. In the last 3 hooks the integers could be node ID's.
It does not work that way right now, though, as far as I know. See template_preprocess_page() and theme_get_suggestions().
EDIT:
Since the __% pattern is the default way to work with numeric args in paths, it is in fact the other way around, i.e. one should consider/ register non default (non hyphens) overrides for the "node" router path.
EDIT2: Replaced wildcard with integers. It doesn't make sense otherwise.
Comment #11
roam2345 commentedNow I am confused... read this http://api.drupal.org/api/drupal/modules--field--field.module/function/t... I think it working correctly now?
Comment #12
eric_a commented@jucallme. Every theme hook has its own default suggestions, i.e. default suggestions for field are different from the default suggestions for page.
Comment #13
jhodgdonWhat are we saying needs documentation here, exactly?
Comment #14
roam2345 commentedThe page templating naming conventions.
Comment #15
EvanDonovan commented@jhodgdon: The fact that the override of a page.tpl.php for node/17 is page--node--17.tpl.php (i.e., two occurrances of the double hyphen, rather than the 2nd one being a single hyphen).
Comment #16
jhodgdonHmmm. Then we should probably put this onto the Theme Upgrade 6/7 page, as well as some theming page in the Handbook (not that the D7 theming guide really exists at this point)? Adding a tag for update doc accordingly.
Comment #17
EvanDonovan commentedA D7 theming guide would be an awesome place for this :) I so wish that I wasn't as busy with work this time of year....
Comment #18
jhodgdonThis was long-ago documented:
http://drupal.org/update/themes/6/7#template_files_double_hyphen
I added a note specifically about page templates, since the examples in that section didn't have multiple levels of template overrides.