Using PHP to Rewrite Views 3 Output

Last updated on
28 March 2019

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

In your view edit page, go to Advanced -> Other -> Theme: Information. Its dialog will expose all the theme files that are called for your view. You can use generic to very detailed theme files that will only be use for your views display.

The first file name in Display output is views-view.tpl.php. That will apply to all views and displays. The next one in the list is views-view--[view name].tpl.php. It will only apply to your view. It keeps drilling down until it gets as specific as possible. views-view--[view name]--default.tpl.php is the last one in the list and only applies to the default display of the view.

Clicking the Display output: link will expose the template code that views uses. Simply copy and create a new template file with one of the suggested names in the list. It's usually best to be as specific as possible. The template file can go anywhere in your theme and views will pick it up as long as you rescan template files in the theming information and save the view. There are view templates, row templates, field templates and field specific templates.

Orginal Post http://drupal.stackexchange.com/questions/935/views-3-and-html5-how-to-o...

Help improve this page

Page status: No known problems

You can: