Created
August 19, 2013 20:08
-
-
Save csarsam/6273483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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