I need to create a block with eg the latest comments on the site. when using views, concegui select the data I wanted, but the problem is that I need to edit the output of view (specify the html). I tried to make a tpl, but the fields when they get to this, are already formatted ([#markup]). also tried to make a block programmatically by accessing the fields of view, via $comments = views_get_view('last_opinions');, but so the fields do not bring content, but for example, ids (for referrals), or integers (in the case of dates), ....

basically, how to change views output?

3 Answers 3


Views out but can be changed at every stage of the process upto the field level.

You can check the theme information in the other section towards the bottom of the right vertical tabs. There you would see the list of theme templates you can use. The last one is where the fields get themed. and moving upwards each of the wrapping themes such as the row theme the entire page theme etc. The name suggestion are also there in the same place.

You can make the template as specific as you want.

  • thanks for the reply. As I understand from your answer, that would create a tpl for each of the fields for the row and the row style, because I want to modify almost everything. is not there a better way? Jan 19, 2013 at 0:16
  • what kind of change do you want to apply to the html and the purpose of the same? Jan 19, 2013 at 4:39

Views has a set of hooks that you can use as well as template files.

If you don't want to use tpl.php files then use hooks.

This is probably what you want but there are plenty of others that are easy to find on api.drupal.org:


If that's not powerful enough for you then you can also write your own Views handlers that extend the existing handler classes OOP-style and just change how things are rendered there.


If you want to change exposed filter form in view then use hook_views_exposed_form to Change the exposed form output.

if your view is for listing some content type data then you can use tpl and tpl naming convension is in theme information on bottom of right side in advance.

then in tpl you can get $rows variable and iterate over this for data but you can change the listing design like table or div layout.

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.