I have become in love with Display Suite. I am going to incorporate it into every site I build, from now on. It is amazing. Thanks for all your work on this.
Now, I have customized my Search Results, but I have this function in my template.php file, to group the results by content type:
function THEMENAME_preprocess_search_results(&$variables) {
$variables['search_results'] = '';
// get a list of node types
$nodeTypes = node_get_types();
// loop through results, group by type
$resultTypes = array();
foreach ($variables['results'] as $result)
{
$resultTypes[$result['node']->type][] = $result;
}
// create fieldsets for each type
foreach ($resultTypes as $resultType => $resultTypeResults)
{
$value = "";
// loop through entries
foreach ($resultTypeResults as $result)
{
$value .= theme('search_result', $result, $variables['type']);
}
// add fieldset
$variables['search_results'] .= theme('fieldset',
array(
'#title' => $nodeTypes[$resultType]->name,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#value' => $value,
)
);
}
$variables['pager'] = theme('pager', NULL, 10, 0);
// Provide alternate search results template.
$variables['template_files'][] = 'search-results-'. $variables['type'];
}
It no longer works with ND Search. I imagine there must be a way to tweak this code to get it to work, since it just overrides the search results function, much like ND does. Any ideas? I would not abandon DS for this functionality, but it would be nice to have.
Thanks!
Comments
Comment #1
swentel commentedLook into nd_contrib/nd_search/nd_search.module. Depending on the search type (core, apachesolr ..) a function can be implemented to completely override the theming of the search results page. See node_search_page() or apachesolr_search_search_page() in that file. That means, any preprocess functions don't run anymore, that's the downside of it. So if you have custom modules in your project, you can actually do this yourself as well and even disable nd_search completely. Also, I think you should be able to take your preprocess function and do this:
I'm going to move this to Display Suite 7 version because I like the idea, so this will available in that version. This won't be backported normally since I stopped adding new features to the D6 branch right now, all focus is on D7. You think you have enough info with this ?
Comment #2
swentel commentedBetter title for the new feature
Comment #3
swentel commentedI've committed this to the D7 version of Display Suite. Again, I've looked for a possible backport, but that would break existing configurations of other people which I don't want too.
Attached is screenshot of how it works.
Comment #4
caponey commentedwell, i tried and tried, but it was beyond me =)
i found out how to get search terms in views arguments though, so I can group them that way, and still use the Display Suite search results layout. Perfect.
thanks again for all you do swentel!
Comment #6
puhig commentedHi,
I would customized my Search Results group by node, my core searh is apache solr, Is possible get a similar view than post #3 ?
Thanks
Comment #7
waqarit commentedi have found a workable code to solve above issue without using DS.
Comment #8
nareshbw commented@waqariz - This code is ok . But here is one bug for it suppose total items are more then 10 so this field set will create for initial 10 items only . Other items will come on next page .
Comment #9
nareshbw commentedI used custom_apachesolr_query_alter($query) hook to overcome this problem .