Drupal 6: Template Suggestions for nodes in your View
When themeing your view in Drupal 6, you have the ability to override the default templates. Depending on the "Style" and the "Row Style" attributes that you assign your view, different options are available to you. If you choose a "Node" row style, you can take advantage of a special template suggestion. You can create a .tpl file in your theme directory with the following naming scheme: node-view-VIEWNAME.tpl.php This template will be used to render each node in the view. It works almost the same as node-NODE TYPE.tpl.php but only for the view that you have specified.



Comments
Does a node-based View with
Does a node-based View with a customized template have better performance than a field-based View with several fields from the node?
P.S. Your captcha is nearly impossible.
fields vs node
actually it does not since it loads the entire node object.
Also re template names – in addition to node-view-VIEWNAME.tpl.php you can also use node-view-VIEWNAME-DISPLAYNAME.tpl.php
But views is not using the
But views is not using the node_lod(nid) cached way?
I tried your suggestion,
I tried your suggestion, but it doesn’t work (or I’m doing something wrong)
Instead, I have successful used views-view-fields—VIEWNAME.tpl.php instead of node-view-VIEWNAME.tpl.php
In the case of crashes, an
In the case of crashes, an export from MSInfo32, which you can launch by simply typing MSInfo32 into the Run box on your Start menu, so that we can see information about the operating system, running software and application errors.
Does a node-based View with a
Does a node-based View with a customized template have better performance than a field-based View with several fields from the node?
mpcoc
Yes,it has better performance
Yes,it has better performance than node based view.I can say this surely as i have implemented this and i have experience the performance difference.
Thanks!
I think you just saved me lots of hair pulling, thanks you!
What am I doing wrong?
Hi, I'm hoping that someone can help me figure this out.
I'm building an Ubercart store, and I have a Vocabulary called "Brands". I created a Views view called "brands_view" to show all the products for each brand. I'm using D6.9 and Views2.2.
The view works using UI, but I need to add text to a field. Later, I would also like to merge two text fields into one string, so I can have "product_name By brand_name" as one on some views. For now, I'll settle for adding "By " to the front of the Term.
But I can't even seem to override one field template to add text.
I used "Theme Information" to get the filename I need to override the Term field.
I created views-view-field--brands-view--default--tid.tpl.php, placed it in my bluemarine folder (using it for both admin and production, for testing) and added some test text just so I could see it working.
I rescan Template files and Views sees it! I run a Preview, and it works! I'm home free, right?
Well, no. I go to my brands view page .... nothing! It doesn't get picked up!
I've emptied Views Cache and overall cache with devel.module and the Theme Registry has been reset, but my View doesn't show the changes!
I even created the suggestions hierarchy of files (views-view-field--brands-view--default--tid.tpl.php, views-view-grid--brands-view--default.tpl.php, views-view-fields--brands-view--default.tpl.php) thinking that woudl work but still .. nothing!
Has anyone else experienced this? It makes it kind of hard to theme my site when I can't alter my views appearance.
Note, I have 2 non-views templates: node-product.tpl.php and node.tpl.php. That works!
But Views templates? Not working. I'm wondering if there's a big bug in Drupal 6, but I have no idea.
I've spent the last few days scanning tutorials to see if I missed anything, but I think I'm doing everything right!
AAAAARRRRGGGGGGGHHHHHHHH! Okay, that helps to scream.
Anyway, any ideas are much appreciated. Thanks.
I know the answer, now. My curse is lifted.
Theme Information suggested this:
views-view-field--taxonomy-term--default--tid.tpl.php
and that didn't work, and it drove me nuts. This works:
views-view-field--taxonomy-term--tid.tpl.php
The display name "--default' should not be there. Phew!
And ....... exhale!
You should have added a display to your default view
I'm not sure, but I believe you get better performance if you add a display type to your view. If it's a block, then you add a block display. If it's a page, add a page display.
Make sure to save the view after adding a display type to it.
Awesome, great tutorial .
Awesome, great tutorial . Thanks for sharing cobro
About the template!
Hi guys concerning issues with template files, just do this simple thing: click on "theme" in the "basic settings" area. A series of templates will appear at the bottom of the page. You will a bold template name beside each plugin name. That is the template actually used for that plugin.
Each of the names reported in each row can be used as a template. Simply create a file with that name in your drupal theme's folder. Then reanalyze template files, then click ok, and then save your view. From now on you can modify your template in your theme folder and it will be used to display the nodes in your view. If you choose "node" as your row style (in basic settings) the views module will use the node default template, and this is a great thing I've just discovered. Hope this helps!
Thanks for this article!
I'm using the multiflex3
I'm using the multiflex3 theme on Drupal 5. I've created my frontpage using views, mini-panels and panelpage (its basically a panel page containing a few mini-panels and views). I did not use the theme's right-sidebar rather I sliced my panel-page to have a fixed-sized right column to display the adverts
But in the node page (when any node is clicked) the right column disappears, but I want a side bar to appear on the node pages as well and put an specific view there. If I enable the theme's right sidebar (to be displayed on the Node page) it ruins my front-page layout as well.
Any solution? I really appreciate your article and would be grateful if you could help me out. search engine optimization
Cheers
Hi
Thanks for providing nice tutorials. It really awesome information.you can also find a lot on Free Blogs
Post new comment