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

MrMaksimize’s picture

Assigned: MrMaksimize » Unassigned
Toxid’s picture

I can confirm this, __ should be --.

johnbarclay’s picture

I 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.

effulgentsia’s picture

Here'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';.

kenneth.venken’s picture

StatusFileSize
new563 bytes

This patch might be a start. It changes the hook names to template file names for the template suggestions.

Edit: sorry, patch is wrong

kenneth.venken’s picture

StatusFileSize
new566 bytes

Here is the correct one

kenneth.venken’s picture

Status: Active » Needs review
StatusFileSize
new2.14 KB

This 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.

Zen’s picture

Component: User interface » Code
StatusFileSize
new2.74 KB

Kenneth'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

effulgentsia’s picture

@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.

Zen’s picture

Repost (more or less). Even with the size difference, I'm pretty sure that it's the same patch. Please review.

-K

effulgentsia’s picture

StatusFileSize
new2.49 KB

Here's an alternate implementation. Can someone test this and verify that it achieves the same thing?

kenneth.venken’s picture

Status: Needs review » Reviewed & tested by the community

Nice improvements to my original patch. It works beautifully.

eojthebrave’s picture

I can also confirm that the patch in #11 works. And it would be great to have it included in the module.

Fidelix’s picture

#11 works for me too.

heather’s picture

Ah! I was wondering about this. Was just about to report this bug :)

+ 1 to this patch.

itangalo’s picture

+1 on the patch in #11. Works like a charm.

ñull’s picture

Here too I can confirm that this works. Please submit!

moshe weitzman’s picture

Status: Reviewed & tested by the community » Fixed

Committed 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.

effulgentsia’s picture

Thanks, 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.

heather’s picture

WOOT! Thanks, Moshe! This little patch is going to make this awesome module even happier.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.