Change Drupal Views Rows before they were rendered I want to change the output of a view. More precisely i want to reduce the resulting list to exact 3 matches: one specific row and its previous and next row.

As far as I understand I need to generate the whole list first, because otherwise i cant find the previous row. So I thought I have to do something in the views-view.tpl where all the rows will printed.

My question then is: How can I get the content of a specific field in each row in $rows so i can check for that specific row and its surrounding rows?

Or is there any better way?

ps. ( i am a php noob )
A custom module which implements hook_views_pre_render() will give your that ability:

&lt;?php
MYMODULE_views_pre_render(&amp;$view) {
  if ($view-&gt;name=='myview') {
    // limit the results to 3
    array_splice($view-&gt;result, 3);

    //other modifications can be done as well:
    foreach($view-&gt;result as $r =&gt; $result) {
      // do something
    }
  }
}


to find a specific row you'll have to code a bit, but that's not drupal related, check https://stackoverflow.com/questions/1019076/how-to-search-by-key-value-in-a-multidimensional-array-in-php for further informations.