1. 6.x-3.x theme/theme.inc views_templates
  2. 7.x-3.x theme/theme.inc views_templates

All views templates can be overridden with a variety of names, using the view, the display ID of the view, the display type of the view, or some combination thereof.

For each view, there will be a minimum of two templates used. The first is used for all views: views-view.tpl.php.

The second template is determined by the style selected for the view. Note that certain aspects of the view can also change which style is used; for example, arguments which provide a summary view might change the style to one of the special summary styles.

The default style for all views is views-view-unformatted.tpl.php

Many styles will then farm out the actual display of each row to a row style; the default row style is views-view-fields.tpl.php.

Here is an example of all the templates that will be tried in the following case:

View, named foobar. Style: unformatted. Row style: Fields. Display: Page.

  • views-view--foobar--page.tpl.php
  • views-view--page.tpl.php
  • views-view--foobar.tpl.php
  • views-view.tpl.php
  • views-view-unformatted--foobar--page.tpl.php
  • views-view-unformatted--page.tpl.php
  • views-view-unformatted--foobar.tpl.php
  • views-view-unformatted.tpl.php
  • views-view-fields--foobar--page.tpl.php
  • views-view-fields--page.tpl.php
  • views-view-fields--foobar.tpl.php
  • views-view-fields.tpl.php

Important! When adding a new template to your theme, be sure to flush the theme registry cache!

See also

_views_theme_functions()

File

theme/theme.inc, line 1114
Preprocessors and helper functions to make theming easier.

Files

Namesort descending Location Description
views-exposed-form.tpl.php theme/views-exposed-form.tpl.php This template handles the layout of the views exposed filter form.
views-more.tpl.php theme/views-more.tpl.php Theme the more link.
views-view--frontpage.tpl.php test_templates/views-view--frontpage.tpl.php Main view template.
views-view-fields.tpl.php theme/views-view-fields.tpl.php Default simple view template to all the fields as a row.
views-view-grid.tpl.php theme/views-view-grid.tpl.php Default simple view template to display a rows in a grid.
views-view-list.tpl.php theme/views-view-list.tpl.php Default simple view template to display a list of rows.
views-view-row-comment.tpl.php theme/views-view-row-comment.tpl.php Default simple view template to display a single comment.
views-view-row-rss.tpl.php theme/views-view-row-rss.tpl.php Default view template to display a item in an RSS feed.
views-view-rss.tpl.php theme/views-view-rss.tpl.php Default template for feed displays that use the RSS style.
views-view-summary-unformatted.tpl.php theme/views-view-summary-unformatted.tpl.php Default simple view template to display a group of summary lines.
views-view-summary.tpl.php theme/views-view-summary.tpl.php Default simple view template to display a list of summary lines.
views-view-table.tpl.php theme/views-view-table.tpl.php Template to display a view as a table.
views-view-unformatted.tpl.php theme/views-view-unformatted.tpl.php Default simple view template to display a list of rows.
views-view.tpl.php theme/views-view.tpl.php Main view template.

Comments

greatmatter’s picture

If you want to theme for "Content" (what is really a node), copy the node.tpl.php to a file name that fits the mask "node--view--[VIEW-NAME].tpl.php. Refresh your cache. You're done!

alexdmccabe’s picture

This didn't work for me.

I have a field being used as a grouping field, and that field is being output as "rendered content". This causes it to use the node.tpl.php in the relevant theme to render the content. Is this not the kind of situation you were talking about?

TheodorosPloumis’s picture

views-exposed-form--view_name--machine_name.tpl.php

Example: views-exposed-form--latest_nodes--page.tpl.php

lhugg’s picture

I can't get this to override the tpl.php provided in views. I've flushed caches, deleted js cache files, turned off any cacheing I can think of. Editing views-exposed-form.tpl.php in its original location works fine, but Drupal won't recognize it as an override anywhere else, either by the original name or refined as Theodoros shows here. Any thoughts?

thecoolestguy’s picture

Is this for Drupal 6 or 7? I don't know if it's the case in 7 (in my experience, it hasn't been), but in Drupal 6, you need to copy the unchanged template to the same directory. So, copy views-exposed-form.tpl.php to your THEME_NAME/templates directory, and then copy it again in the same directory and rename the new copy.... Edit the newly-renamed copy, but keep the original in there with it.

dev.paulson’s picture

views-exposed-form--view_name--machine_name.tpl.php works for me.
To know more about the templates. Please create a form alter in your custom module and see what is printed for the following code.
if($form_id == 'views_exposed_form'){
print_r($form);
}
Then navigate to #theme section. Then create a file in your theme templates folder with the file name specified in 0th position in #theme array.
Dont forget to replace _ with - while creating theme file.

kabitakis’s picture

You may add
views-view-field--foobar--page--field_name.tpl.php
to the examples. Used to format a specific field of a display of a view.
Note the first "field" (no "s").