Created
September 19, 2013 09:15
-
-
Save danreb/6621014 to your computer and use it in GitHub Desktop.
Useful in removing duplicate node in taxonomy term display page when using views
This file contains hidden or 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
<?php | |
/* | |
* Check node ID to remove duplicate result. | |
* | |
*/ | |
function MODULENAME_views_pre_render(&$view) { | |
//dpm($view->name); | |
if ($view->name == 'taxonomy_term') { | |
$nids = array(); | |
foreach ($view->result as $row) { | |
/* Do we have this nid already? */ | |
if (!isset($nids[$row->nid])) { | |
/* No, add this row to the output array */ | |
$result[] = $row; | |
/* record that we have this nid */ | |
$nids[$row->nid] = $row->nid; | |
} | |
} | |
/* Return the new results set */ | |
return $view->result = $result; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Drupal 7 code