oooh it was that theme_ function!
Over the last 2 years one of my main headaches have been to figure out where a given part of the site were comming from - a lot of late nights of backtracking could have been avoided I just had read this übertrick from Todd Nienkerk (or i got the brain to figured it ;))
The Trick is super simple, i stumbled across it a couple of days ago while I was struggling with form theming, and thought that this was way to sweet to hold for my self. what this does is show you what theme functions is called - oooh foooorking yeah!
Go into you drupal sites root and go to includes/theme.inc and jump into the theme() function around line 170 chance the call_user_func_array to include a little comment with the theme functions:
#000000">#0000BB"><?php
#007700">return #DD0000">'<!-- begin ' #007700">. #0000BB">$functions#007700">[#0000BB">$function#007700">] . #DD0000">' -->' #007700">. #0000BB">call_user_func_array#007700">(#0000BB">$functions#007700">[#0000BB">$function#007700">], #0000BB">$args#007700">) . #DD0000">'<!-- end ' #007700">. #0000BB">$functions#007700">[#0000BB">$function#007700">] . #DD0000">' -->'#007700">;
#FF8000">// return call_user_func_array($functions[$function], $args);
#0000BB">?>Voila and now everytime Drupal5 is evil and not understand what your saying - jump into the source code and get the answer, and smack it into place - how goddamn cool is that!
offcourse this little hack will make the source look like crap, so what i do is to use it in my local MAMP setup, but not in a live site.
... why is it I just figured this out now - when im slowly working to convert to D6?
btw sorry for the crappy formatting of the code, my input filters are screwing with me - anyone got a hammer?


This should be core!
This should be core!
Core should not output debug
Core should not output debug info. This is good for development.
Have you tried the devel module Morten?
devel module with krumo is
devel module with krumo is like firebug, and coffee a themer must have ;)
Soohit Dgeezus!
Best 2008 themer trick.
Really nice hack (for
Really nice hack (for development site) - definitely no-no for production.
one tiny issue...
It seems this also prints out :
<!-- begin phptemplate_page --><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">as the very first line, messing up IE's strict rendering mode. How can I get it to NOT print for this particular function? I'm not much of a coder.
well its not ment for the
well its not ment for the production enviroment - not on a live site.
This is just a hack to give a themer an idea of where the different elements of the site is coming from
Very true, however if in a
Very true, however if in a staging site, if it's not rendering how it'll render in production, it kind of defeats the purpose. :-( Anyway, here's the bit of code I have to render things nicely for IE, and keep it out of quirks mode.
if ($functions[$function]) {if ($functions[$function] == 'phptemplate_page') {
return call_user_func_array($functions[$function], $args);
}
else{
return '<!-- begin ' . $functions[$function] . ' -->' . call_user_func_array($functions[$function], $args) . '<!-- end ' . $functions[$function] . ' -->';
}
}
This is a total life saver. :-)
devel_themer?
The devel_themer module does this with all kinds of fancy ajax magic in Drupal 6. However, thinking about it, with the theme registry you should be able to use the same trick devel_themer does to inject that sort of wrapping on every theme function except theme_page() without touching core.
I smell devel_themer patch coming... Who wants to do it? :-)
Update: Instructions added to Drupal.org
I've updated the Drupal.org page Using Theme Override Functions [in Drupal 5.x and earlier] to include these instructions.
Just so we're totally clear: This should never be done on a production site! This is a temporary hacking of core intended only for development environments.
jup but its soooo sweet a
jup but its soooo sweet a trick :)
Pingback