Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

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.

share|improve this answer
    
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? –  Miguel Borges Jan 19 '13 at 0:16
    
what kind of change do you want to apply to the html and the purpose of the same? –  Mohammed Shameem Jan 19 '13 at 4:39
add comment

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:

http://api.drupal.org/api/views/views.api.php/function/hook_views_pre_render/7

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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