views:

152

answers:

1

I'm a little new to drupal but have been using things like devel module and theme developer to speed up the learning process.

My question, is it possible to theme an entire views BLOCK from a single views tpl.php page OR even a preprocess?

When I'm grabbing the $view object I can see results $node->result, it has all of the results, but it doesn't have all my views fields. I'm missing things like, node path, taxonomy titles and paths, etc.

From my understanding, Drupal wants you to individually theme EACH output field. It seems rather superfluous to create so many extra templates when I've already got over HALF of my results coming through the $view object

Would outputting node over field make this easier? Or am going in the wrong direction with $view->result?

Thanks!

+1  A: 

this page might help: http://drupal.org/node/342132

I rarely theme at the views field level -- agreed: it's too many files to edit. So I either do it at the node/teaser level, or load the view programmatically, and then display it in a function in my glue module.

whether to do nodes or fields depends on how else you're displaying the items. for example, if the only way you're using teasers is in this view, it might simplify things to do the theming in the node-mytype.tpl.php file. If you have four different views, all of which have different themes, you might use the glue module approach. There's also the css-only appraoch. Or, sometimes, views theming truly is the best option.

update: you can also use node_load in your glue module to get more node info. That can be expensive, performance-wise, depending on the size of your view and how often the nodes change. (node_load does some caching...)

sprugman
Thanks sprug! I guess my expectations were set a bit too high from node theming, these suggestions should keep me busy for awhile!
askon