I'm using the iCal display and the iCal view to offer iCalendar downloads for items of my own content type "Event". The description within the VEVENT block should contain the event title, the event body and the event website.

I configured the "iCal" display mode to contain title, body and website field in plain text mode. While the title and the body are formatted properly, the website url is appended directly at the end of the body text.

For example:

BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
X-WR-CALNAME;VALUE=TEXT:My calendar
PRODID:-//Drupal iCal API//EN
BEGIN:VEVENT
UID:calendar.2761.field_period.0
SUMMARY:My birthday party
DTSTAMP:20120510T141310Z
DTSTART;VALUE=DATE:20120503
DTEND;VALUE=DATE:20120510
URL;VALUE=URI:http://localhost/en/events/my-birthday-party
DESCRIPTION:======== MY BIRTHDAY PARTY ======================================\n \n Let's celebrate my birthday. Beer is on me, you bring the food.http://www.happybirthday.com/
END:VEVENT
END:VCALENDAR

What I actually need is the website url to appear in its own line:

BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
X-WR-CALNAME;VALUE=TEXT:My calendar
PRODID:-//Drupal iCal API//EN
BEGIN:VEVENT
UID:calendar.2761.field_period.0
SUMMARY:My birthday party
DTSTAMP:20120510T141310Z
DTSTART;VALUE=DATE:20120503
DTEND;VALUE=DATE:20120510
URL;VALUE=URI:http://localhost/en/events/my-birthday-party
DESCRIPTION:======== MY BIRTHDAY PARTY ======================================\n \n Let's celebrate my birthday. Beer is on me, you bring the food.\n \n http://www.happybirthday.com/
END:VEVENT
END:VCALENDAR

Any hints how to do this? Why would one want to concatenate all fields without spaces or new lines?

CommentFileSizeAuthor
#6 iCal_screenshot.jpg174.2 KBwizbard
#1 screenshot.png44.95 KBjustin.koh
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

justin.koh’s picture

FileSize
44.95 KB

I need to do this as well, and couldn't figure out the template override for the specific field, in a specific display mode, of the specific content type...

My temporary solution is to edit the label on the field to include a literal "\n". For example, if you want a newline between the body and website field, make the label of the website field "\n \n", or "\n \nWebsite" (assuming colon is added automatically). Probably requires Display Suite? I forget :P

Attached an example screenshot:

coredumperror’s picture

Status: Active » Closed (fixed)

This should bes fixed in the 7.x-2.x branch. Please download the 7.x-2.x-dev build and try it out.

wizbard’s picture

Version: 7.x-1.1 » 7.x-2.x-dev

Hi, I have had the same problem and could not get either the 7.x-2.x-dev or the 7.x-2.3 updates to give me a new line for each field. I tried using the "Force using fields" option to see if that would help, but to no avail. One thing, I did start developing the feed when using 7.x-2.0. Do I need to delete the feed display and start over?

FYI, I also tried the "\n" workaround by adding it to the field title. It did work, but for some reason, I'm getting "unsolicited /n" codes in the feed, adding extra lines where I don't want them.

Feeling foolish,

-wiz

coredumperror’s picture

Status: Closed (fixed) » Active

Hmmm, now that I think about it, the method I used to separate each field into a different line wasn't applied in Date iCal. I used Display Suite to format my fields differently.

The reason that these fields are getting concatenated, rather than separated by a newline, is that drupal_html_to_text() doesn't treat <div> as a paragraph separator (like it does for <p>), so it just assumes that text in consecutive divs is in the same paragraph.

Unfortunately, I don't really know if there's anything that Date iCal can do about that. I don't know of any other method by which to strip the HTML tags (which is required by the iCal standard). So, the best advice I can give is to either wrap your fields in <p>s, or use Display Suite to customize exactly how your fields get rendered in the iCal view mode.

If anyone knows any better solutions to this issue, please let me know.

P.S. The "Force using Fields" option has no effect, because of the way that Date iCal renders the output of the view. At one point I tried changing the mechanism to use Fields, instead of the iCal view mode, so that I could detect the boundary between fields and add a newline myself. Unfortunately, I couldn't find any good method by which to implement the change, so I had to fall back to the iCal view mode method.

wizbard’s picture

Thanks so much! Will try it first thing tomorrow and let you know, but this sounds like the "ticket."

wizbard’s picture

FileSize
174.2 KB

Well, I've been dinking with both the

and the Display Suite options, but without success in iCal. The

moves the field down, but puts an extra line between it and the label. I couldn't find the right combination in Display Suite, either. Unless someone has some step-by-step ideas, I guess I'll just hope that a future revision of Date iCal makes gives this option. I'll attach a screengrab in case... I can also email the ics file if someone wants to see it. Thanks for the suggestions, though.

coredumperror’s picture

Status: Active » Fixed

You're in luck! I figured out how to give users more control over how the HTML gets converted into plaintext for the iCal feed.

There's a hook in the new Date iCal 7.x-2.4, hook_date_ical_html_alter(), which will let you define a function in one of your modules which can manipulate the Description and Summary HTML before it gets sent to drupal_html_to_text(). Just wrap <p> tags around each of your fields, and they'll become newlines in the iCal feed.

wizbard’s picture

Update: I'm still having trouble, but I suspect the problem is procedural on my part, so in my next entry, I'll describe my step-by-step process to see if another set of eyes can spot my error.

But I've got a couple of other fires with several other websites, so I may not get to it today.

Thanks, though. I feel like I'm close.

-wiz

ABQ Slim’s picture

"Just wrap

tags around each of your fields"

I can't edit the "machine name" of the fields because I have lots of data currently populating my calendar. If I put "

" in front and behind the Labels of the fields then they will show up everywhere. I have a feeling I'm misunderstanding your explanation. Would you please be more specific as to where I need to add the

? Thanks!
Tony

coredumperror’s picture

That instruction is for using hook_date_ical_html_alter(), not for changing anything to do with Labels. If you're not a programmer, you won't really be able to use hook_date_ical_html_alter(). Unfortunately, it's the best solution I can offer because of the limitations presented by Drupal's HTML to Text conversion.

The only other effective solution is to use Display Suite to customize how your fields are rendered. Though that will also require some programming knowledge, since you'll probably have to write some custom DS fields.

markusk’s picture

I found another workaround for those who want to avoid installing the Display Suite module: wrapping the fields into Field groups within the iCal view mode will also give you newlines. You may define an optional label to the field value as well. As I was using Field groups anyway on my site, there was no need for another module.

Markus

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mastoll’s picture

Another solution that requires no programming:

In your iCal feed view
- use Show=iCal Fields w/ Settings>Description field=content:body
- add all of the fields that you want to display in the description to the view's fields, arranged with the content:body field last in the list
- rewrite the results of the content:body field, using tokens to add the contents each of fields from your list
- add <p> and </p> tags around each field's token

You may find that some fields don't need <p> tags. For example, in my compilation of fields, I have an 'item URL' field token following the token for the contents of the original body field. These are already separated from each other, so I don't put a <p> tag around the body field.

coredumperror’s picture

The iCal Fields plugin did not exist when this issue was originally posted. Only the "iCal Entities" plugin was available.