It took me ages to work out how the theme hooks worked because I couldn't find any documentation, until I found this:
http://www.agileapproach.com/blog-entry/theming-views-drupal-6

Would be a useful inclusion under theming in advanced help. =)

(If it is there already, apologies, but it's really tough to find!)

Comments

merlinofchaos’s picture

Status: Active » Closed (won't fix)

That page is misleading; it's using a lot of theme functions, but Views really wants you to use theme templates. That's why it's not documented...you're not supposed to use them like that.

The theme: information in a view tells you the templates that view uses, and the help button from theme: information leads into the theme documentation in the advanced help.

greg.harvey’s picture

Thanks for the reply. There are situations where I might prefer to use that though.

For example, if I had 20 views, each with 5 fields, and I needed to have bespoke output, down to the individual field level, I'd end up with 120 tpl files just for my views, right? That's an unmanageable number of templates. That's exactly the situation I find myself in, hence favouring the use of template.php *in this special case only* ...

I totally appreciate that 99.9% of the time templates are the way to do, but I personally think it would be useful to advise of the existence of the above while strongly advising the use of templates in most cases ...?

merlinofchaos’s picture

My feeling is that there are some hitches to using theme functions; primarily that preprocess functions won't be run, which means some things will not be properly set up the way you'd like. This is a bigger problem than can be dealt with with just documentation, making it an Experts Option Only. The theme functions will need to be significantly more complex than the theming templates are.

An Expert should be able to piece together the theme function name from the template name (in fact, the rule is simple: Replace all - with _ and themename as a prefix). One can look in views_theme() or use devel's theme registry editor to see what the arguments to the function are. I'm okay with forcing people to go through these hoops to use that method, because documenting it means I have to support it; whereas, leaving it not specifically documented (though it is largely documented if you understand the theme system) means I can blow it off as an experts only, and assume that experts can figure out how to deal with the preprocessing foo.

Also, if it helps, you can organize your templates in sub-directories and they will not be paid attention to during the template discovery process. That might make it easier to deal with having hundreds of templates.

greg.harvey’s picture

Fair enough.

Also, if it helps, you can organize your templates in sub-directories and they will not be paid attention to during the template discovery process. That might make it easier to deal with having hundreds of templates.

That's interesting. I missed that! Thanks! =)

EugenMayer’s picture

Title: Theming hooks documentation » Theming hooks information under "Theming information"
Version: 6.x-2.x-dev » 6.x-3.x-dev
Status: Closed (won't fix) » Active

I just hijack this issue, as its kind of the same topic ( making the use of those hooks / preprocess hooks easier). What about just show them under Theming information while editing the view, similar to the theming templates? Would make this help even more useful and complete.

MustangGB’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)