I have a view with a field with multiple images, and i limit the output to just 1 image, the first one. Everything worked fine until i translated drupal with the locale module of the core to spanish. It started to print all images and it threw this error:
Notice: Undefined index: es en views_handler_field_field->get_items() (línea 562 de /var/www/drupal_prueba/drupal7_prueba/sites/all/modules/views/modules/field/views_handler_field_field.inc).
I resolved changing the line 562 and 587:
562 $all_values = $entity->{$this->definition['field_name']}[$langcode];
587 $entity->{$this->definition['field_name']}[$langcode] = $new_values;
I changed $langcode, with 'und', and it worked. But of course, surely this isn't the way to do it.
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | 1070744-field_language-37.patch | 1.99 KB | zambrey |
| #34 | using_field_language-1070744-32.patch | 1.99 KB | derhasi |
| #32 | 1070744-field_language.patch | 1.18 KB | kdebaas |
| #31 | 1070744-field_language.patch | 1.17 KB | dawehner |
| #27 | views_export-deals_photos_slideshow.txt | 9.49 KB | Jerome F |
Comments
Comment #1
dagmarI saw this issue a few days ago. This patch fix the problem.
However, field_language function is not called anymore. I don't know the implicacances of this.
Comment #2
bojanz commentedIt breaks translatable fields. Which is worse then a notice ;)
Comment #3
pcambraGetting this same error, suscribe
Comment #4
metalinspired commentedSame here. However, I noticed that if I change the active language and error is gone. Still trying to figure out why.
Edit: Got rid of error by putting Content translation: Language (= Current user's language) into filters
Comment #5
dagomar commented+1 Subscribing
Comment #6
roam2345 commentedFollowing this one
Comment #7
roam2345 commentedfollowing this one
Comment #8
kdebaas commentedI have a similar issue. A view of nodes with multiple imagefields (displaying only the first one), looks all right in english. In spanish, it prints all the images from untranslated nodes. I am using entity translation, with language fallback, and the image fields are translateable. The errormessage reads:
Notice: Undefined index: es en views_handler_field_field->set_items() (línea 676 de /home/kdb/web/example/modules/views/modules/field/views_handler_field_field.inc).Comment #9
EndEd commentedIn my case i get this error...
Notice: Undefined index: en in views_handler_field_field->set_items() (line 676 of C:\damp\www\es_gshop\sites\all\modules\views\modules\field\views_handler_field_field.inc).
...when i use in a view an image field with multiples images in it and tried to display the first one. Also no matter how i configure the Multiple field settings of the image field, I always see all images so i can not really only select the first one to see.
Comment #10
aristeides commentedsubscribing
Comment #11
FallinHigh commentedsubscribing
Comment #12
mrsimonelliott commentedI don't have the solution to this but I made an observation.
If node language is set to the same as default site language then views showing a single image from a multi-images field work as expected. If you change the site default lang or the node lang, the view outputs the error mentioned above and displays all images from the multi-field regardless of the view config.
We have only discussed multi image fields, I'm pretty sure this behaviour would be apparent whatever type of multi-field you are using.
This screen shot shows a view of two nodes of the same type, both with multiple images attached, the first node's language does not match site default lang, the second node's language does.
https://skitch.com/mrsimonelliott/r9fti/kledij-bashop
Comment #13
xandeadx commentedsubscribing
how to reproduce error - http://drupal.org/node/1137408#comment-4389128
Comment #14
zambrey commentedsubscribing
Comment #15
dagmarWhat about this?
Comment #16
yatil commentedsubscribe
Comment #17
jamsilver commentedConfirmed that the patch in #15 solves my problem. Re-rolling the patch since the call to $this->field_language does nothing with this approach.
It looks unlikely that this is the right solution however since it looks like
$this->field_languagelooks in some query settings and performs some substitutions?Comment #18
bojanz commentedYes, that's still a wrong solution.
Comment #19
anruethersubscribe
Comment #20
skilip commentedsubscribe. Patch in #17 did remove the error. I cannot confirm this it the right solution either though.
Comment #21
Jerome F commentedNotice: Undefined index: en in views_handler_field_field->set_items() (line 676 of (...)/sites/all/modules/views/modules/field/views_handler_field_field.inc).I confirm the image field with multiple values is not handled by views as configured. This view used to work before the activation of multilingual internationalisation modules.
Comment #22
Jerome F commentedThis is breaking all my views, it's a really problematic issue.
Changed status according to @bojanz comment #18 and because the patch in #17 doesn't apply to last dev anymore.
And I submitted an issue in internationalisation views as well, as this is an issue only in a multilingual website: http://drupal.org/node/1169556
Comment #23
sonojacker commentedI agree. I have been skimming through the "translation" module code, where we may get the more liable solution, as far as their function is not providing the value Views is instructed to use. Pls comment.
Comment #24
controla commentedsubscribing
Comment #25
controla commentedsubscribing
Comment #26
Jerome F commentedI reference to #18, @bojanz in your opinion what needs to be done to solve this problem correctly?
Comment #27
Jerome F commentedI use some views with multiple image fields, displaying only the first one and/or displaying each value on a single row. In english it worked ok, but once the translation modules are enabled, this bug breaks the views handling of multiple values fields.
In views, in the field edit form in Multiple field settings, when "Display all values in the same row" is unchecked, nothing is displayed in the view.
"Display 1 value(s)" doesn't work either, it displays the images as if "Display all values in the same row" was used.
Please find attached a view export for a simple multiple image field.
EDIT for clarification
Comment #28
Toktik commentedsame problem. subscribing
Comment #29
Toktik commented#17 patch works for me.
Comment #30
mac_weber commentedsubs
Comment #31
dawehnerTo sum up
* It should be possible to configure which language is used in the views interface: current/default/none
* It should be taken care that always an value is returned. field_language takes care of this
The problems on all this is the following:
* If no field translation is enabled, but locale module installed you still have 'und' for the field storage.
So here is a patch. This patch has to be tested and reviewed by as many people as possible!
Comment #32
kdebaas commentedThanks! I applied the patch, and my views now work as expected.
I re-uploaded the patch, with some minor corrections of the English used in the comments.
re: * If no field translation is enabled, but locale module installed you still have 'und' for the field storage.: I believe another case scenario is when you are using language fallback, such as provided by the entity translation module (when language fallback is enabled, if a translation is not available for the requested language an existing one will be displayed). In that case the field is not stored as "und", but still causes the problems your patch solves.
Comment #33
derhasi commented@dereine, I altered your patch (as discussed in IRC), so
field_language()is now called in$this->field_language().Field language is a main function of core's Field Language API, so we won't get around using it.
The patch in #31 and this one differ from #17, as they consider the language of the view, by passing it to
field_language().As dereine mentioned, this patch has to be tested and reviewed by as many people as possible! So, dear subscribers, please help to bring it in ;)
Comment #34
derhasi commented... arg ... forgot the patch file... there it is:
Comment #35
kdebaas commentedWorks for me.
+ // field_language takes sure that if the $langcode key doesn't exist LANGUAGE_NONE is used.minor spelling mistake: takes->makes
Comment #36
pcambraApplied patch in #34, the notices go away for me :)
Comment #37
zambrey commentedWorks as advertised, thanks.
Fixed spelling mistake mentioned by kdebaas
Comment #38
dawehnerFor me this looks now fine, but bojanz should really have a look at so assign to him
Comment #39
Jerome F commentedsubscribe - I will definitely test this.
Comment #40
bojanz commentedThe fix is correct. Great community work, everyone!
The comment was a bit fuzzy to me, although it gives a good example.
Maybe something like this would be better:
Leaving the final judgement to dereine.
Comment #41
cpelham commentedWorks for me, too.
Comment #42
dawehnerGreat. Commited to 7.x-3.x
Comment #43
Jerome F commentedhttp://drupal.org/node/1167292 marked as duplicate.
Thank you, last git today fixes the issue!
Comment #44
Pocketpain commentedHey, I get an error while trying to patch with Drush.
Am I doing anything wrong when I:
1. Download patch.
2. Go to cd ..drupal/sites/all/modules/views/modules/field in Terminal
3. Type: patch < 1070744-field_language-37.patch
It says it failed on HUNK #1 at 644 and I get alot of more errors when I reload views.
Thanks!
Comment #45
dawehnerNo this is not drush, that's normal bash.
patch -p1 < FILENAME is what you want.
In general you don't have to patch views, use the dev version.
Comment #47
eigentor commentedHad the same issue, fixed with 7.x-3.0-rc1 of views now.
An Issue that still appears to persist, though, is: if one does not check "display all results in the same row" in the multiple field settings, nothing gets displayed.
Or is there another issue for this?
Comment #48
dawehnerDo you know some more informations? Are this field actually empty on this particular node?
Sure there are always at least two issues :)
Comment #49
eigentor commentedNo, the fields are not empty.
I tried another time and get a different result now :P
When I uncheck the "display all results in the same row", it displays all images of the first node, but none of the other nodes. I tell the view to use a pager and show 15 results on each page.
Here is the View I am referring to http://adventure-manufactory.com/de/tajik/tajik-image-galleries
The Galleries are single nodes with multiple Image fields and 10-20 images per field.
Cannot get my head round how this should look like, but shouldn't all images of all nodes be there with a pager?
Comment #50
dawehner@eigentor
Which version did you used on this site?
In general i would recommend to run dev and test the patch from http://drupal.org/node/1303398
Comment #51
eigentor commentedO.K.
For me personally this is not so important at the moment.
So I'll keep track if I have the problem later again.
Comment #52
dawehnerWell it sorts of lacks information how to reproduce it. http://drupal.org/node/571990 is in general i fine description about this whole topic.
Comment #53
eigentor commentedPersonally I can't say much more than I have nodes with imagefields with multiple images (set to unlimited), and a view that displays the images together with a title.
The view shall display only the first image of each field, which it does if I select "display all results in the same row" but doesn't if I do not select that.
The problem only appears if the locale module is enabled.
But you probably need more specific info...
Comment #54
tim.plunkettSetting back to fixed as it was in #42.
If this is still an problem, please open a new issue with clear steps to reproduce.