Views Row Theming

On this podcast episode, Bob shows you a really powerful and robust way to theme your Views output using a set of under-documented variables. This method will give you faster load times on your views and will give you amazing flexibility and node-style layouts of each of your views. This is powerful stuff, folks! This method was investigated and worked out at a Detroit Drupal meetup with @mattfarina and @jasonrsavino

Man, I wish you had of put this up about two weeks ago when I was trying to figure it out! I ended up creating a whole bunch of files with ridiculous file names in order to theme each field (names like "views-view-field--ministry-gallery--block-1--field-gallery-image-fid.tpl.php"). Besides performance, you may have to theme your view this way if you need more options to display your data then just node or teaser. On our site we have 4 different views for the same nodes, and each view needs to be custom themed. A question about performance: If you have reasonable caching on your view, shouldn't performance become a non-issue? So what if drupal loads extraneous information about the node if it's only doing it once?
I agree that I may have lingered too long talking about performance reasons for using this method. In reality, I'll be doing it because it's more flexible (seeing performance as an extra benefit)...imagine that each view could have it's own "teaser" rather than relying on what's in your node template. I know that fields should be better for performance, how much? I don't know for sure, I leave that developers :) But from what I'm told, it should be pretty significant. Regardless, this is flexible and powerful for many other reasons, I think.
The field ID is also displayed in the browser's status bar when you hover over the field on the view edit page.
This video came right in time for me! I've played with Drupal a bit before, enough to learn some things about CCK and Views, but this is the problem I had been hitting every time!
You made a reference to node themeing and in the example it looks like a good way to give custom css. Do you have a tutorial on that or can you point to some references to it.
I've started using this method for some of my designs, but have noticed that there is a side effect in that node hit counts are no longer counted (as no full nodes are being viewed) I have a instance of using fields to display announcements randomly, but I'd like to even out the views by making sure each is viewed the same number of times. My initial thought was to set up the view to show 1, then sort by number of 'Total Views' ascending... as a announcement was viewed, it would be moved to the end of the list. Unfortunately, since the node statistics aren't changing, neither is which announcement is shown. I've switched back to complete random for now. Is there anything I can do to make this work like I want it? Thanx!
Excellent video. Can this also be used to control what fields are displayed in your FileField Podcaster module? It would be great to chose what is outputed in the podcast body/description.
I had exactly the same sentence in my mind when I seeing this … Great «a-ha!»-moment. I will re-theme my sites as soon as possible. Thanks!
Hi, I liked a lot the idea of "dynamic classes" in the row tpl file. Do you know if there is a way to print the "key" value of a select list text field instead of the "label" value. Like that I can use the key to give the names to my classes and still use any charachter and name I want for my labels in case I need them on other parts of my website. Thanks for the amazing podcasts Ciao Marco
Actually printing ->raw instead of ->content is doing what I need. Just I don't know if it is the "elegant" way for doing it. Anyway at least is working.
Hi Bob, your video is exactly what I need. Thanks for your work!!!
Hi Bob, I not a very good coder. I was wondering I have been having problem with server database requests limit. Tell me is theming nodes and view increase performance more than using Panels? to restate my question : in term of performance is it better to go ahead an try to theme node and views, than using panels ? Thank you
Bob, First of all, you help me a lot with your screen-casts. Thanks a lot for that. Where do you find the time to do all this ? I've got a question about theming Views and specially YouTube videos in Views. What is the best way find the part of the code to rewrite? I've made a View with 4 videos (2 one to another) and i want to style these (border, background-color, etc.). I did it with the title. Do i just have to try one by one all the .tpl.php files ? Again thank you. Paul
Great, very inspiring!
Wow, I've been searching for hours trying to figure out how to do this one very thing. This rules! Perfect!
Hi, I like you way of explaining things. Thanks. I was trying to add a view to a node so it would override the node.tpl.php and use fields as you explained. The thing is that I get nothing to show. What are the parameters one should use in order to manipulate the node view? Thanks Rani
Hey thank you so much you have helped me out so much, What editor are you using? Thanks!