Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When adding an image field to a view using a search API index, an image field will always show all of the items even though it has been set to display only one image in the 'Multiple field settings'. I tested some other options in the 'multiple field settings', here is a list of what doesn't work:
- Display all values in the same row
- All check boxes/options at the bottom
This functionality works as expected in a view of 'Content'. Not sure which module could be causing this, so any help would be appreciated.
Comment | File | Size | Author |
---|---|---|---|
#8 | entity_views_multiple_fields_options.patch | 1.51 KB | fago |
Comments
Comment #1
MrGeneric CreditAttribution: MrGeneric commentedWhilst trying to trace the problem I found if I commented out the following line:
in.../modules/entity/views/handlers/entity_views_handler_field_field.inc, then the problem resolved itself. Maybe this help to trace the problem.
Comment #2
drunken monkeyPlease wait for #1231512: Use real Relationships instead of level magic in Views integration (which will completely re-vamp the display part of the Views integration, and will probably be committed on Monday) and see if the problem still occurs then.
Comment #3
MrGeneric CreditAttribution: MrGeneric commentedOK. I should point out that i was using patch 47 from that thread when this issue occurred. Thanks for all your hard work, It is a really nice improvement.
Comment #4
drunken monkeyAh, yes, of course. It has been committed now (with slight changes) so please just use HEAD now.
The bug is in the Entity API part of the code, so please move this issue there or re-open #1266036: Add generic Views entity tables with fields and relationships.
Comment #5
MrGeneric CreditAttribution: MrGeneric commentedJust had a chance to upgrade to latest entity/ search api dev releases and can confirm this is still an issue. Moving to Entity API as requested.
Comment #6
jaymallison CreditAttribution: jaymallison commentedsubscribed.
Comment #7
modstore CreditAttribution: modstore commentedI am also having this same problem.
Comment #8
fagoAttached patch should fix it, please test.
Comment #9
jaymallison CreditAttribution: jaymallison commented#8 works for me. I assume the forced "Display all values in the same row" was intentional due to other limitations in Entity API? Either way it's nbd for me. This now works for me as I need it to.
Thank you for the patch, I can remove my hack I had to do to get around this.
Comment #10
fagothanks for testing, committed.
Comment #12
magtak CreditAttribution: magtak commentedStill experiencing this problem with latest (today's) dev version of Entity API and Search API. Do I need to apply the older #8 patch nonetheless?
Comment #13
magtak CreditAttribution: magtak commentedJust checked manually, the patch is applied, the problems still persists though. Using CSS to hide the additional data for the time being
Comment #14
kasalla CreditAttribution: kasalla commented#8 thanks, works great for me!
D7, Ubercart 3.dev, Search API
Comment #15
MickC CreditAttribution: MickC commentedProblem persists with 7.x-1,5 even though this patch is committed.
Images from a referenced entity can be added as related fields, firstly as referenced-entity: image "the file", then as image fields related to that.
So I can get the URL as described here, and option @2 works but only if there is a single value in the field.
Views is not providing the Multiple Values option, so multiple values appear as a string of URLs in which case the image does not appear.
Would appreciate some help to be able to do either of these things:
a) force views to treat as a multiple value field
b) force Search API to only index the first value
Comment #16
drunken monkeyThis can be done with the "Aggregated fields" data alteration, and its aggregation type "First".
However, the displayed entities usually don't reflect the indexed data, this is only the case when using Solr and checking "Return results data from Solr" (or similar) in the server options.
Comment #17
NWOM CreditAttribution: NWOM commented@drunken monkey: Is there a way currently to aggregate by "Last" instead of "First"?
Comment #18
drunken monkeyNo, but it should be simple to add this yourself – either by directly modifying the existing data alteration or by copying the code to create a new, custom one.