Insert row into a view I have a view which fetches nodes from content type A, arranges them in a grid and uses a displaysuite buildmode to render them...nothing fancy so far. Now I want to insert a specific node of content type B at a specific position in the grid...like this:


+----------+----------+
|          |          |
|  type A  |  type A  |
|          |          |
+----------+----------+
|          |          |
|  type B  |  type A  |
|          |          |
+----------+----------+
|  type A  |  type A  |
.          .          .


I'm not sure where to start. I was hoping there would be some hook, preprocess function or whatever where I get an array of node objects to insert my special node into which then gets rendered...
I found the function I was looking for. You can insert nodes in the results array just after the query has been executed.

This goes in the module:


function modulename_views_post_execute(&$view) {
  // wait for the right view
  if($view->name == "name_of_the_view") {
    // create the object you want to insert in the result
    $temp = new stdClass;
    // creation date of that node   
    $temp->node_created = 1314807643;
    // nodeID
    $temp->nid = 13;

    $new_result_array = array();
    $i = 0;
    foreach($view->result as $single_result) {
      if($i == 2) {
        // insert the extra node at 3rd position
        $new_result_array[] = $temp;
        $new_result_array[] = $single_result;
      } else {
        $new_result_array[] = $single_result;
      }
      $i++;
    }
    // replace the old result array
    $view->result = $new_result_array;
  }
}