🇨🇭Switzerland @mrupsidown

Account created on 14 January 2013, almost 12 years ago
#

Recent comments

🇨🇭Switzerland mrupsidown

mrupsidown created an issue.

🇨🇭Switzerland mrupsidown

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.

🇨🇭Switzerland mrupsidown

#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.

🇨🇭Switzerland mrupsidown

#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.

🇨🇭Switzerland mrupsidown

How many more years until the most basic module documentation is clear?

🇨🇭Switzerland mrupsidown

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.

🇨🇭Switzerland mrupsidown

Thanks for the details!

Production build 0.71.5 2024