Last updated March 25, 2011. Created by junedkazi on April 19, 2009.
Edited by drumm, jhodgdon. Log in to edit this page.
Note: I have requested that this be added to Advanced Help in the Views module - see http://drupal.org/node/495626
To alter a view before it is rendered we can use hook_views_pre_render(&$view).
To view a list of views api refer to http://views.doc.logrus.com/ .
To use this function we must add this function to the module file
<?php
function modulename_views_pre_render(&$view) {
}
?>Just to make sure you only alter the view you want we will add a condition at the very top of this function to check if it is correct view.
Suppose your view name is "foobar". Then the code will look something like this.
<?php
function modulename_views_pre_render(&$view) {
if($view->name == "foobar") {
//Add code to manipulate the view
}
}
?>To view an example of how to alter a view footer check this out
http://drupal.org/node/422264#comment-1466510
Comments
details
This looks like a good start, but I think that many people looking for an example of hook views pre_render() are going to end up here, and end up going no further. Currently on the web, there are exactly zero (0) tutorials or examples on hacking views pre_render. The linked issue is helpful but limited.
Those who know, perhaps a working example would help. (The issues queue contains many cases of users looking to filter views results due to duplicate fields in rows [a JOIN issue], or looking to dynamically set view title using fields from results).