It's been breaking my brain, but theme developer displays the wrong suggestions for template overrides in d7. I've tried with html5_base and zen. Example:
html.tpl.php, override suggested as html__front.tpl.php, real override: html--front.tpl.php
It's been breaking my brain, but theme developer displays the wrong suggestions for template overrides in d7. I've tried with html5_base and zen. Example:
html.tpl.php, override suggested as html__front.tpl.php, real override: html--front.tpl.php
Comments
Comment #1
MrMaksimize commentedComment #2
Toxid commentedI can confirm this, __ should be --.
Comment #3
johnbarclay commentedI tried to write a patch for this, but cannot figure out where the __ is generated. Does this module use the core theme engine to get template suggestions? I grepped on -- __ and 2 and found no related code. If we can't fix this, a patch saying in the output that it doesn't work would be better than nothing.
I often recommend this module to themers, so its a scarey bug.
Comment #4
effulgentsia commentedHere's some info in case it's helpful for whoever wants to work on this. Theme hook names use "_". For example, 'comment_wrapper'. This is what shows up as the key name within the theme registry array. The hook could be implemented with a function or a template. If your theme implements it with a function, then the function is named 'YOURTHEME_comment_wrapper'. If your theme implements it as a template, then the template is named 'comment-wrapper.tpl.php' ("_" converted to "-", and ".tpl.php" extension added).
Suggestions may or may not be implemented (hence, the name "suggestion"). For example, your theme might have a 'html--front.tpl.php', or it might not. If it is implemented, you can look up the template name in the theme registry (
$registry = theme_get_registry(); $registry['html__front']['template'];). If it's not implemented, then $registry['html__front'] won't exist, but if it makes sense to display the suggestion within Theme Developer as what the template file would need to be named, then you can use do something like$template_name = strtr($suggestion, '_', '-') . '.tpl.php';.Comment #5
kenneth.venken commentedThis patch might be a start. It changes the hook names to template file names for the template suggestions.
Edit: sorry, patch is wrong
Comment #6
kenneth.venken commentedHere is the correct one
Comment #7
kenneth.venken commentedThis patch correctly displays the template names for both the 'Parents' field and the 'Candidate template files'.
I also use $meta['hook'] as name instead of $meta['name'] since name contains the $hook argument to theme() and can contain an array of suggestions.
Comment #8
Zen commentedKenneth's patch works. I've sanitised it a little further for some formatting glitches as well as missing documentation. I've also replaced strtr with str_replace for efficiency. I've not really looked at the other changes in detail.
-K
Comment #9
effulgentsia commented@Zen: can you please repost your patch? Clicking the link in #8 shows a "page not found". I don't know if it's the spaces, other non-alphanumeric characters, or too long a file name.
Comment #10
Zen commentedRepost (more or less). Even with the size difference, I'm pretty sure that it's the same patch. Please review.
-K
Comment #11
effulgentsia commentedHere's an alternate implementation. Can someone test this and verify that it achieves the same thing?
Comment #12
kenneth.venken commentedNice improvements to my original patch. It works beautifully.
Comment #13
eojthebraveI can also confirm that the patch in #11 works. And it would be great to have it included in the module.
Comment #14
Fidelix commented#11 works for me too.
Comment #15
heather commentedAh! I was wondering about this. Was just about to report this bug :)
+ 1 to this patch.
Comment #16
itangalo commented+1 on the patch in #11. Works like a charm.
Comment #17
ñull commentedHere too I can confirm that this works. Please submit!
Comment #18
moshe weitzman commentedCommitted to master. This module looks quite inactive, so I just committed this without checking with other maintainers. Hope I did not step on anyone's toes. I was the original author of this module. Feel free to revert and reopen this issue if I screwed up.
Comment #19
effulgentsia commentedThanks, Moshe. I just updated the project page to indicate that another co-maintainer would be most welcome. I know some of you have been helping out a lot in the issue queue. If anyone wants commit access to the repository, please review http://drupal.org/node/363367 and contact me. Thanks.
Comment #20
heather commentedWOOT! Thanks, Moshe! This little patch is going to make this awesome module even happier.