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.
Updated: Comment #4
Problem/Motivation
If the AddToCal format is used on any view_mode other than "Default". When the entity is viewed with any other view_mode the following error displays:
Notice: Undefined index: location_field in addtocal_extract_event_info() (line 300 of /var/www/sites/all/modules/addtocal/addtocal.module).
Notice: Undefined index: description_field in addtocal_extract_event_info() (line 301 of /var/www/sites/all/modules/addtocal/addtocal.module).
No matter if Location & Description format options are chosen.
Proposed resolution
The patch from comment #3 avoids the error message. But the Location and Description are not populated into the AddToCal, unless the view_mode for the entity is "default". So the patch in comment #3 doesn't get to the root of the problem.
Comment | File | Size | Author |
---|---|---|---|
#34 | location_description-1785452-34.patch | 465 bytes | Anonymous (not verified) |
#27 | location_description-1785452-27.patch | 9.66 KB | Anonymous (not verified) |
#17 | addtocal-location_description_missing-1785452-17.patch | 5.35 KB | heddn |
#11 | addtocal-location_description_missing-1785452-11.patch | 5.34 KB | heddn |
#10 | addtocal-location_description_missing-1785452-10.patch | 5.66 KB | heddn |
Comments
Comment #1
Marty2081 CreditAttribution: Marty2081 commentedWe had the same notices. It turns out that we use the 'full' view mode instead of the 'default' view mode and that the module uses the 'default' view mode in the next line of code:
$display = field_get_display($instance, 'default', $entity);
For now, we changed the code to use the 'full' view mode. Would be nice if the appropriate view mode would be determined by the module.
Comment #2
timmay CreditAttribution: timmay commentedThank you -- changing to 'full' view mode worked for my site as well.
Comment #3
lookatthosemoose CreditAttribution: lookatthosemoose commentedHere's a patch that checks for the existence of the 'location' and 'description' array keys before using the variables.
This patch is against the 7.x-1.x-dev branch.
Comment #4
markabur CreditAttribution: markabur commentedPatch in #3 works for me.
Comment #5
dooug CreditAttribution: dooug commentedI also got the error "Undefined index: location_field in addtocal_extract_event_info() with 7.x-1.x-dev.
The patch in comment #3 avoids the error. However, the problem still exists that 'default' view_mode is hardcoded, and the location & description fields will not work unless you are using that view_mode.
I debugged a bit, the
addtocal_field_formatter_view()
callsaddtocal_extract_event_info()
which hasdefault
hardcoded in line 350.hook_field_formatter_view()
should not be dependant on one view_mode. Basically this is following bad practice, and I have yet to determine the best practice for this to work properly on all view modes.Comment #6
kendouglass CreditAttribution: kendouglass commentedComment #7
anneeasterling CreditAttribution: anneeasterling commentedConfirming that "patching" line 350 to use 'full' allows the display of the location and description on non-default display modes.
Another issue: Using the select option to link to a Location field didn't work. I had to use tokens to get the field to actually display. Adding a note here to help Googlers/searchers.
Comment #8
GrahamShepherd CreditAttribution: GrahamShepherd commentedAnne Easterling (#7), could you please explain your points a bit more clearly? Particularly the "patch" you refer to in para 1 and the use of tokens in your para 2.
Comment #9
heddnI'm working on a patch today that will pass the description and location as query parameters on the URL. By the time one gets to the hook_menu callback for ICS and Outlook, the defined view_mode is no longer available. And it isn't possible to introspect the view_mode from within hook_field_formatter_view() and pass that in the query. So we are stuck with passing the values on the URL. This is OK, because URLs max out at 2000 characters and ics maxes out at around 1000 characters so we have plenty of room.
Comment #10
heddnBTW, I've moved this to critical since the module is essentially useless unless this gets fixed.
Attached patch fixes location and description as mentioned in #1785452-9: Location & Description only work if using the 'default' view_mode. It also fixes a bothersome bug with
characters getting inserted un-escaped into ics and google calendar invites. If I need to pull that out and put in a separate issue I can do that.
Comment #11
heddnThis removes the
stuff. That is fixed more appropriately in #2206231: ICS file formatting issues: MS Outlook / ICS Description.
Comment #12
lord_of_freaks CreditAttribution: lord_of_freaks commented#11 isnNot working for me .. probably the patch needs to be rerolled ...
Thanks in advance
Comment #13
heddn@lord_of_freaks, are you using the dev version of the codebase?
Comment #14
heddnUnassigning myself
Comment #15
lord_of_freaks CreditAttribution: lord_of_freaks commentedHi @heddn
From my project.make file
I´m getting an error when i´m trying to patch the file with
I´m getting:
Comment #16
deardagny CreditAttribution: deardagny commentedConfirming the same result as @lord_of_freaks when trying to patch. I'm using the latest dev as of 8/29.
Comment #17
heddnReroll of #11.
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #20
Anonymous (not verified) CreditAttribution: Anonymous commentedPatch looks good, and has been committed. Thanks everyone!
Comment #21
deardagny CreditAttribution: deardagny commentedIs everybody having luck with this commit? I'm getting a new error:
Comment #22
deardagny CreditAttribution: deardagny commentedSorry to reopen this but I've installed and reinstalled the latest dev and I'm still having issues.
The Google and Yahoo options successfully populate the titles and dates/times, but location and description are still left blank. The iCal and Outlook links now result in a "page not available" message from the browser.
I'm also getting several errors in the dblog about undefined variables (display and timezone) and missing arguments. Just want to verify that this update is working for others. Thanks!
Comment #23
bmelvin1 CreditAttribution: bmelvin1 commentedI'm seeing the behavior reported by deardagny. The Google and Yahoo options call addtocal_extract_event_info with no "display", so it doesn't know how to load the description or location. In contrast, addtocal_download_ics uses a description and location that has been passed via URL. Seems like that could also be done with Google and Yahoo, but it's a technique I'd rather avoid because of limited url length.
Comment #24
Anonymous (not verified) CreditAttribution: Anonymous commentedFix in the works; stay tuned.
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commentedDo we have an update on this? This module provides key features for a client site. Any feedback appreciated so we can set an expectation
Comment #26
Anonymous (not verified) CreditAttribution: Anonymous commentedPatch coming this afternoon!
Comment #27
Anonymous (not verified) CreditAttribution: Anonymous commentedHere is an initial patch for this issue. I'd like to get a few folks testing it before committing it, if possible.
Comment #28
Anonymous (not verified) CreditAttribution: Anonymous commentedOUTSTANDING!!!!! #27 Works as described Thank You!!!!!
Comment #30
Anonymous (not verified) CreditAttribution: Anonymous commentedPatch committed.
Comment #31
kenheim CreditAttribution: kenheim commentedWorks great for Google and Yahoo, but it is not providing correct dates/times for Outlook.
Comment #32
kenheim CreditAttribution: kenheim commentedSorry. I didn't notice that this had been closed. I reopened it for the comment I posted above.
Comment #33
Anonymous (not verified) CreditAttribution: Anonymous commentedI'll take another look at the .ics export.
Comment #34
Anonymous (not verified) CreditAttribution: Anonymous commentedLooks like that was an oversight in the refactor. Here's the correction to the .ics file export; looks like it works locally in iCal, but I'd right appreciate it if someone has a minute to test it with Outlook as well.
Comment #35
kenheim CreditAttribution: kenheim commentedExcellent. Looks like the patch solved it for Outlook. Thanks for such a quick fix!
Comment #37
Anonymous (not verified) CreditAttribution: Anonymous commentedI've committed that latest patch, and once again will be closing this. Hopefully this time no more latent bugs reveal themselves!