DS search "group by type settings" not ordering by weight.

rogernyc's picture

In DS 'displays >> search' in the 'group by type settings' area, setting the weight of the node-type groups is having no effect on the order of the groups in the search result display. They order by 'group label'. I've experimented with the weights, cleared the cache etc with no luck. Am I missing something?

Using DS 7.24, Weight 7.23, Drupal 7.22, Custom search 7.1.1

thanks!

Comments

Same issue here

codyzhao's picture

Display suite: 7.x-2.6
Drupal: 7.26

No custom search installed, the weight is just not doing anything.

I'm seeing it too

mikemoretti's picture

And after looking at the module code, I know it's not sorting this stuff by weight at all but just inserting result groups in order of the results. I made a patch for this. I'll be opening a bug and submitting it there.

I can't attach the patch file here, but here is the text of it in case you have a hard time finding the bug report I post it to; this is based on v7.x-2.7:

*** sites/all/modules/ds/modules/ds_search/ds_search.module 2014-10-28 03:47:46.000000000 -0400
--- ../ds_search.module 2014-11-22 21:54:58.232102702 -0500


*** 311,316 ****
--- 311,323 ----
return theme('ds_search_page', $build);
}

  • function _ds_search_cmp_group_by_weights($a, $b) {
  • if ($a['#weight'] == $b['#weight']) {
  • return 0;
  • }
  • return ($a['#weight'] < $b['#weight']) ? -1 : 1;
  • }
  • /**
    • Helper function to group by type.
      */

*** 380,385 ****
--- 387,393 ----
$parity['ds-other'] = $parity['ds-other'] == 'odd' ? 'even' : 'odd';
}
}
+ uasort($build['search_results'], '_ds_search_cmp_group_by_weights');
}

/**

-Mike