i have a view which is not filtering the duplicated nodes and i tried couple of solutions but it looks like they are not working.
The code I am using is the following.
function mymodule_views_pre_render(ViewExecutable $view) {
if ($view->id() == 'basicnews') {
$unique_nids = $new_results = array();
// Loop through results and filter out duplicate results.
foreach ($view->result as $index => $result) {
if (!in_array($result->nid, $unique_nids)) {
$unique_nids[] = $result->nid;
$new_results[] = $result;
}
// Replace $view->result with new array. Apparently views requires sequentially keyed
// array of results instead of skipping keys (e.g. 0, 2, 4, etc), so we can't just
// unset the duplicates.
$view->result = $new_results;
}
}
}
Is there any patch or work-around for this issue?