Creating a template for a new Drupal view created by the Views module is straight forward.
There are two options available:
- Creating a template for each node that is listed by the view.
- Creating a template for each field that is listed by the view.
Creating a template for each node listed
In the edit View screen, change the Row style type to node.
Drupal will generate the HTML by calling node_view() function which is using the standard node.tpl.php template.
To override Drupal’s default behavior, we need to create a node-view-viewname.tpl.php template file which will be called each time a node is being rendered by the view you defined. If your view is called Articles, you need to name the file: node-view-articles.tpl.php.
Make sure you put the template file in your theme’s directory.
Please note that setting the Row style to node will cause Drupal to load the entire node from the database which may have a performance impact on the web site.
Creating a template for each field listed
In the edit View screen, change the Row style type to fields.
Create views-view-field–viewname–fieldname.tpl.php in your theme’s directory for each field that will be listed by the view you defined. Make sure you set viewname to the view’s name and fieldname to the field’s name.
You can view the file names for each field by clicking on “Theme information” link on the edit view screen.
For additional information check out the Views module help pages.
After creating the template files, make sure you cleared the theme registry by clicking on “Clear cached data” button in Admin > Site Configuration > Performance screen.
If you liked this article, please share it on Digg, Stumble Upon or del.icio.us. Thank you.