Skip to content

Instantly share code, notes, and snippets.

@csarsam
Created August 19, 2013 20:08
Show Gist options
  • Save csarsam/6273483 to your computer and use it in GitHub Desktop.
Save csarsam/6273483 to your computer and use it in GitHub Desktop.
function solur_views_pre_render(&$view) {
//keep track of the node ids that have already been put in the results
$used_nids = array();
$new_view_result = array();
//Go through each result
foreach ($view->result as $row) {
dpm($row);
//Make sure $row->nid has a value; this prevents error messages
if(isset($row->nid)) {
//If the nid is already in the $used_nids array, don't put it in the new view result array
if (!in_array($row->nid, $used_nids, true)) {
$new_view_result[] = $row;
$used_nids[] = $row->nid;
}
}
}
//Set the result to the duplication-free array
$view->result = $new_view_result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment