I have a grouped view that displaces content containing multiple entity references. I have a field that generates multiple times, because of those entity references. I've looked into modifying views-view-group.html.twig with no luck. Now I'm trying to figure out how to use hook_views_pre_render to accomplish this.
(If it comes up... no, using 'Views Field View' didn't work)
I currently have results like this:
Group Title - Item one -- entity-ref1 -- Field-x -- entity-ref2 -- Field-x
I want this:
Group Title - Item one -- entity-ref-item1 -- entity-ref-item2 -- Field x
I've already got the hook set up in a module. I'm just trying to figure out how to use it to rearrange fields and output Field x - After the rest of each entry has output. I haven't found anything.
UPDATE: I tried this solution for removing duplicates - BUT.. it's removing the multiple entity references along with the multiple Field X. I just one Field X pared down to one:
function webinar_rearrange_views_pre_render(\Drupal\views\ViewExecutable $view) {
if ($view->id() == 'webinars') {
$filtered_nids = array();
foreach ($view->result as $key => $row) {
if (in_array($row->nid, $filtered_nids)) {
unset($view->result[$key]); // remove the duplicate
} else {
$filtered_nids[] = $row->nid;
}
}
}
}