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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Marty2081’s picture

We 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.

timmay’s picture

Thank you -- changing to 'full' view mode worked for my site as well.

lookatthosemoose’s picture

Here'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.

markabur’s picture

Status: Active » Needs review

Patch in #3 works for me.

dooug’s picture

Title: Undefined index: location_field in addtocal_extract_event_info() » Location & Description only work if using the 'default' view_mode
Version: 7.x-1.0-beta3 » 7.x-1.x-dev
Issue summary: View changes
Status: Needs review » Needs work

I 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() calls addtocal_extract_event_info() which has default 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.

kendouglass’s picture

anneeasterling’s picture

Confirming 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.

GrahamShepherd’s picture

Anne 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.

heddn’s picture

Assigned: Unassigned » heddn
Priority: Normal » Critical
Status: Needs work » Active

I'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.

heddn’s picture

Status: Active » Needs review
FileSize
5.66 KB

BTW, 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

\n

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.

heddn’s picture

This removes the

\n

stuff. That is fixed more appropriately in #2206231: ICS file formatting issues: MS Outlook / ICS Description.

lord_of_freaks’s picture

#11 isnNot working for me .. probably the patch needs to be rerolled ...

Thanks in advance

heddn’s picture

@lord_of_freaks, are you using the dev version of the codebase?

heddn’s picture

Assigned: heddn » Unassigned

Unassigning myself

lord_of_freaks’s picture

Hi @heddn

From my project.make file

projects[addtocal][subdir] = "contrib"
projects[addtocal][version] = 1.x-dev

I´m getting an error when i´m trying to patch the file with

patch --dry-run --verbose -p1 < addtocal-location_description_missing-1785452-11.patch 

I´m getting:

Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|From 48628446174ebb8c1754742edcfac7c17ff53997 Mon Sep 17 00:00:00 2001
|From: heddn <lucashedding@1463982.no-reply.drupal.org>
|Date: Fri, 25 Jul 2014 09:14:13 -0600
|Subject: [PATCH] Issue #1785452 by lookatthosemoose, heddn | tky: Fixed
| Location & Description only work if using the 'default' view_mode.
|
|---
| addtocal.module | 69 +++++++++++++++++++++++++++++++++++----------------------
| 1 file changed, 42 insertions(+), 27 deletions(-)
|
|diff --git a/addtocal.module b/addtocal.module
|index 5c0aa27..eae18aa 100644
|--- a/addtocal.module
|+++ b/addtocal.module
--------------------------
Patching file addtocal.module using Plan A...
Hunk #1 succeeded at 92 (offset 1 line).
Hunk #2 succeeded at 336 (offset 15 lines).
Hunk #3 succeeded at 355 with fuzz 2 (offset 17 lines).
Hunk #4 succeeded at 429 (offset 18 lines).
Hunk #5 FAILED at 493.
Hunk #6 FAILED at 515.
2 out of 6 hunks FAILED -- saving rejects to file addtocal.module.rej
Hmm...  Ignoring the trailing garbage.
done

deardagny’s picture

Confirming the same result as @lord_of_freaks when trying to patch. I'm using the latest dev as of 8/29.

heddn’s picture

Anonymous’s picture

Assigned: Unassigned »

  • 6c1 committed 5afc569 on 7.x-1.x authored by heddn
    Issue #1785452 by heddn, lookatthosemoose | tky: Fixed Location...
Anonymous’s picture

Status: Needs review » Closed (fixed)

Patch looks good, and has been committed. Thanks everyone!

deardagny’s picture

Is everybody having luck with this commit? I'm getting a new error:

Warning: Missing argument 5 for addtocal_extract_event_info(), called in /var/www/ffd/sites/all/modules/addtocal/addtocal.module on line 571 and defined in addtocal_extract_event_info() (line 367 of /var/www/ffd/sites/all/modules/addtocal/addtocal.module).
Notice: Undefined variable: display in addtocal_extract_event_info() (line 380 of /var/www/ffd/sites/all/modules/addtocal/addtocal.module).
Notice: Undefined variable: display in addtocal_extract_event_info() (line 381 of /var/www/ffd/sites/all/modules/addtocal/addtocal.module).
deardagny’s picture

Status: Closed (fixed) » Active

Sorry 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!

bmelvin1’s picture

I'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.

Anonymous’s picture

Fix in the works; stay tuned.

Anonymous’s picture

Do we have an update on this? This module provides key features for a client site. Any feedback appreciated so we can set an expectation

Anonymous’s picture

Patch coming this afternoon!

Anonymous’s picture

Status: Active » Needs review
FileSize
9.66 KB

Here is an initial patch for this issue. I'd like to get a few folks testing it before committing it, if possible.

Anonymous’s picture

OUTSTANDING!!!!! #27 Works as described Thank You!!!!!

  • 6c1 committed 213f0b8 on 7.x-1.x
    Issue #1785452 by 6c1: Updating menu callbacks to handle view modes.
    
Anonymous’s picture

Status: Needs review » Closed (fixed)

Patch committed.

kenheim’s picture

Works great for Google and Yahoo, but it is not providing correct dates/times for Outlook.

kenheim’s picture

Status: Closed (fixed) » Needs work

Sorry. I didn't notice that this had been closed. I reopened it for the comment I posted above.

Anonymous’s picture

I'll take another look at the .ics export.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
465 bytes

Looks 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.

kenheim’s picture

Excellent. Looks like the patch solved it for Outlook. Thanks for such a quick fix!

  • 6c1 committed 696a05b on 7.x-1.x
    Issue #1785452 by 6c1: Bug fix for .ics timezone export.
    
Anonymous’s picture

Status: Needs review » Closed (fixed)

I've committed that latest patch, and once again will be closing this. Hopefully this time no more latent bugs reveal themselves!