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.
Hi everyone,
I use this module but there is a warning that I wanted to get rid of.
Problem/Motivation
As I said, the problem was a warning on the node page. Here's the warning from a simplytest instance.
Notice: Undefined index: type in template_preprocess_field_slideshow() (line 977 of /home/s9d41c68951e977f/www/sites/default/modules/field_slideshow/field_slideshow.module)
Steps to reproduce :
- Create a new simplytest instance with the field_slideshow module 7.x-2.x-dev
- In a content type of your choice (Basic page for example), create a field type "image". Change the number of values for this field to whatever you like (This warning is displayed even if there is only one image)
- Go to "Manage display" for this content type
- In "Format", put "Slideshow"
- Create a new Basic Page node and put images in the image field
- Go to your newly created node
- The warning should show up
Proposed resolution
The solution is to add a check for the "type" index. The only workaround for this without a patch is to disable errors in your Drupal administration
Remaining tasks
I'll propose a patch then some of you will need to review it.
Thank you.
Comment | File | Size | Author |
---|---|---|---|
#1 | field_slideshow-undifined_index_type-2479977-1.patch | 730 bytes | AndrackOSnack |
Comments
Comment #1
AndrackOSnack CreditAttribution: AndrackOSnack commentedComment #2
AndrackOSnack CreditAttribution: AndrackOSnack commentedComment #4
khiminrm CreditAttribution: khiminrm commented#1 works for me
Comment #5
LaPi CreditAttribution: LaPi commented#1 works for me too, thank you very much!
Comment #6
LaPi CreditAttribution: LaPi commentedSorry, it's not true, I've got the same problem. I applied this patch and this one. When I saved the node there was no errors at all (yuppi!!!!!) but...no slideshow too (of course I checked: no field is set on "hidden"). After a simple refresh I got this error again...
Notice: Undefined index: type in template_preprocess_field_slideshow() (linea 934 di /var/www/geometratiboni.it/sites/all/modules/field_slideshow/field_slideshow.module).
Any ideas?
Comment #7
markabur CreditAttribution: markabur commented#1 works for me. I am just using a multi-value image field, no field collection.
Comment #8
Prashant Singhal CreditAttribution: Prashant Singhal as a volunteer and at QED42 commentedThe patch works fine. Tested this locally. used
git apply --index field_slideshow-undifined_index_type-2479977-1.patch
, the patch applied cleanly. The patch does small check to see if$item["type"]
is set or not.Comment #9
robertgarrigos CreditAttribution: robertgarrigos commentedI'm having this same problem and this patch solved it only partially. I'm getting two errors: in line 926 and line 976. this patch fixed error in line 976, but not 926
Comment #10
featherbellyThe patch works - is the error @robertgarrigos reports at line 926 is connected with
$item["type"]
being undefined?@robertgarrigos - what is the error?
Comment #11
featherbellyMaybe I spoke too soon - if it's the same error could need to add an
isset
to this line:-elseif ($item["type"] == 'image') {
So it becomes:-
elseif ( isset($item["type"]) && $item["type"] == 'image') {
Comment #12
ndiSIGN CreditAttribution: ndiSIGN as a volunteer commentedI was having the same notice on the same lines as #9.
After finding all kind of patching solutions I was reluctant to apply (one of) them, because the exact same setup was working perfectly on another site i've build, so I didn't really feel there needed something to be fixed.
My guess: the notice was created due to changing all kind of settings during the setup process and therefor eventually the index got corrupted.
My solution: I uninstalled both the field_collection and field_slideshow module and decided to start over. This time I entered all neccesary information correct the first time without changing settings afterwards/during the setup process. This did the trick! It's working as expected/designed now.
The fix for the module could be in the area of avoiding messing up the index by changing fields during setup.
Hope to help someone with this solution.
Comment #13
lamp5