Closed (fixed)
Project:
Display Suite
Version:
7.x-2.2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Apr 2013 at 08:29 UTC
Updated:
20 Aug 2013 at 10:47 UTC
I have a use case where I have taxonomy terms in the search result next to nodes. This results in the following warning:
Warning: Creating default object from empty value in ds_search_search_page() (line 343 of ds_search.module).
The warning is due to the use of the key '#node' on line 343:
$build['search_results'][$id]['#node']->ds_search_zebra = $parity;
Entity types other than node will not have this array key, but a key that corresponds with their type. For taxonomy terms, the key is '#term'.
I changed the code into the following to get rid of the warning:
switch ($build['search_results'][$id]['#entity_type']) {
case 'node':
$key = '#node';
break;
case 'taxonomy_term':
$key = '#term';
break;
}
$build['search_results'][$id][$key]->ds_search_zebra = $parity;
This fixes my issue, but there might be a nicer way to determine the right key for an entity type so that it can be solved in a more generic way?
Comments
Comment #1
marty2081 commentedThis might be cleaner already so that when the key is simply the entity_type the module will work by default and you only have to add the exceptions:
Comment #2
JRZ-2 commentedHello,
I have a similar issue getting the following message :
Undefined index: location_taxonomize dans ds_search_search_page() (ligne 264 dans ----/modules/ds/modules/ds_search/ds_search.module).
I'm using apache solr, Facet api, location taxonomize and display suite search.
On the result page, taxonomy terms are not displayed at all under the "other" group, though the facet indicates that they are found.
Thanks for your insights
Comment #3
swentel commentedCommitted based on #2 which should work fine in most cases now indeed.
Note that the group by only works for nodes, so that can't be fixed at all.
Comment #3.0
swentel commentedAnonymized the warning line (removed the site URL and filepath) and translated Dutch words to English for the non-Dutch audience ;)