I have a view that I've created that selects blog posts based on a specific taxonomy term, creating a sort of "Featured Posts" view that I've embedded on the front page of my site. The issue I keep running into is trying to output the view so that each post is semantically marked up using some of the new HTML. I've tried the built-in "Rewrite this field's output", but it ignores the tags I use (ie, article, header, footer) and wraps everything in divs even when I deselect the placeholder tags.

Should I create a overriding views--view_name.tpl.php to rewrite the output of each post as it appears in the view, or do I need to use preprocess hooks in the template.php to affect the output?

I should state that I have basic experience with writing PHP and preprocess hooks, but I can any resources I need to move me down the linke if I'm pointed in the right direction.

3 Answers 3


You'll notice that in your view under the "Style Settings" block there is a link for Theme: Information. It 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 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.

Once you learn how to manipulate view template files it will really open up your design possibilities.

  • Fantastic! Thanks for pointing that out; this will definitely allow more design control. Mar 19, 2011 at 20:32
  • Extending this a bit, consider the HTML5 Tools module as mentioned in this guide to Drupal HTML5; it exposes more HTML5 elements within Views. May 12, 2015 at 17:00

Fences looks like a great module (for Drupal 7) to control views output markup:

Project page:


From the project page:

"Fences is a an easy-to-use tool to specify an HTML element for each field. This element choice will propagate everywhere the field is used, such as teasers, RSS feeds and Views. You don't have to keep re-configuring the same HTML element over and over again every time you display the field."

I like this bit particularly (great for debugging output):

"Best of all, Fences provides leaner markup than Drupal 7 core! And can get rid of the extraneous classes too!"

This is also nice - reducing repetition of work:

"This kind of tool is needed in order to create semantic HTML5 output from Drupal. Without such a tool, you have to create custom field templates in your theme for every field. :("

They've considered the popular alternatives too:

Similar projects include Semantic fields, Field Wrappers and a tool inside the Display Suite extras. But we think this approach is Morefasterbetter™.

Credit to Drupal user rhache for mentioning the Fences Drupal module in their comment on this question Is Semantic Views module obsoleted by Views 3?


You may try semantic views module.

As it says at this issue, it is useful for html5 output.

  • Semantic views is not the instrument for 7, unfortunately May 23, 2012 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.