hook_views_pre_render() to override results of a view I have a view used on a site to show the latest 4 nodes (in teaser mode) of a content type of 'article'.

On some Article pages the administrator can override some or all of the 4 nodes to be shown in this view.

I have an entity reference field in this content type where they can optionally select up to 4 nodes to feature instead, then in my template.php I have the following code:

function adaptivetheme_subtheme_views_pre_render(&amp;$view) {
    if($view-&gt;name == "related_articles") {

        if ((arg(0) == 'node') &amp;&amp; is_numeric(arg(1))) {
            $node = node_load(arg(1));
        }

        if(isset($node) &amp;&amp; $node-&gt;type == 'article') {

            foreach($node-&gt;field_related_articles['und'] as $key=&gt;$override) {
                if(!empty($override)) {
                    $view-&gt;result[$key]-&gt;nid = $override['target_id'];
                }
            }

            dsm($view);
         }

       }
}


I can see in the DSM output that the values in the results array of the view are changed correctly, but the actual rendered view has blank spaces in place of the inserted nodes.

Where am I going wrong?
Per the first two comments here you should probably use hook_views_post_execute. If you have paged data this will cause issues.