- π©πͺGermany vistree
This is still a problem - also in Drupal 10. Any update on how to solve this issue?
Create a view with a multi-valued field that is display multiple values in the same row, then add a filter or sort on that multi-valued field, or a field on an entity that is related via that multi-valued field, then duplicate rows will show in the results.
Don't show duplicate rows when the multi-valued field is contained in a single row, while still allowing filtering and sorting on those rows.
This workaround removed the duplicate rows, but the number of rows displayed on a page might be less than the configured setting, as each deleted row still took up a "slot" on the page when the query was run.
/**
* Implements hook_views_pre_render().
*/
function my_module_views_pre_render(ViewExecutable $view): void {
switch ($view->id()) {
case 'my_view_id':
// Ensure there's only one row per group.
// See https://www.drupal.org/project/drupal/issues/2721691
$combined = [];
foreach ($view->result as $row) {
if (!isset($combined[$row->_entity->id()])) {
$combined[$row->_entity->id()] = $row;
}
}
// Replace the result set with the combined result.
$view->result = $combined;
$view->total_rows = count($combined);
break;
}
}
I have a multivalued date field on a content type, and a view showing all published items of that content type. Adding an exposed sort by field_date to the view creates duplicate rows for content items which have multiple values in the date field.
Desired behavior: Adding a sort on a multivalue field on a view should expose additional options for how to sort that field, or should default to the first field item.
Active
11.0 π₯
Last updated
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
This is still a problem - also in Drupal 10. Any update on how to solve this issue?