mrupsidown → created an issue.
mrupsidown → created an issue.
I finally got it working by altering the query this way :
/**
* Implements hook_query_alter().
*/
function my_module_query_alter(Drupal\Core\Database\Query\AlterableInterface $query) {
if ($query->hasTag('my_view_tag')) {
// Add the nid field with a groupby function.
$query->addField('node_field_data', 'nid', 'node_field_data_nid', ['function' => 'groupby']);
// Group results by node ID.
$query->groupBy('node_field_data.nid');
}
}
I have added a specific tag in the View settings so I can identify the views I am after. Not sure whether this is the (temporary) way to go but it seems to work for my use case. I see no more duplicates and the number of results per page is correct.
#117 applies for me on 10.2.2 but I see no change whatsoever to my view results. I have tried with "Distinct" and "Disable automatic base field for relationships" or any combination of the two. I still have the exact same duplicates showing.
My view is setup to show 18 items. I see one node 8 times, another node 3 times, 2 other nodes 2 times. In other words, only 3 nodes on my page are not duplicates! This is driving me nuts. The only thing I was able to achieve is by using hook_views_pre_render which allows me to remove duplicates but this will break the number of items displayed in the view. I see 7 items instead of 18, which corresponds to every non-duplicated item in my original view result.
#23 "works" in the way that it removes duplicates, but my view is setup to display 18 items and when using this method, I get 18 results minus the removed duplicates.
How many more years until the most basic module documentation is clear?
mrupsidown → created an issue.
Ah... I found that out just before you replied. This should be in the docs really... It's quite unclear you need a "link" field type. I had tried with almost every other field. Thanks.
mrupsidown → created an issue.
Thanks for the details!
mrupsidown → created an issue.