My company is getting ready to switch over to Office 365. We're looking to use exchange calendars for events (we're a school system of three schools and there a lot of calendars with a lot of events). In the hope of not having to double enter most of our events, we are trying to use exchange's publish feature (which creates an ics file) with feeds and Date ical to directly import the whole mess.
Now to my question, since I'm fairly certain microsoft has not provided me a way to change what gets put into the ics file (which does not include categories) I am hoping to find a way to use the X-WR-CALNAME to map as a taxonomy term. Problem, this module looks at each event and maps only the items that exist for each event. Is there a way to get the X-WR-CALNAME and apply it to all events mapped by the feed?
Comment | File | Size | Author |
---|---|---|---|
#8 | calendar_categorizer.zip | 1.79 KB | coredumperror |
Comments
Comment #1
coredumperror CreditAttribution: coredumperror commentedYou sure can! Date iCal provides a number of alter hooks for the import process, which you can implement in a custom module to tweak the data before it gets processed into nodes.
Your best bet is probably to implement
hook_date_ical_import_component_alter()
to change each component (event) in the calendar. That hook gets passed the full calendar object as part of its context (check out thedate_ical.api.php
file for the full docs on this hook), so you'd be able to extract the X-WR-CALNAME from it and place it into the CATEGORIES property of each event.Since you'll be messing around with the objects provided by iCalcreator, you'll need to learn a bit about how they're laid out. If you check out the code in
includes/DateiCalFeedsParser.inc
, you'll see how I interact with those objects (vcalendar and vevent objects, mostly), which should be a good starting point. You may also want to read the iCalcreator documentation.Comment #2
modulo49 CreditAttribution: modulo49 commentedThanks for the quick reply. This is further than I normally go into php, but I'll give it a go.
Comment #3
coredumperror CreditAttribution: coredumperror commentedIf you have trouble, please let me know.
Comment #4
modulo49 CreditAttribution: modulo49 commentedI would appreciate any help you can give. I can write a few little php scripts, but hooks and custom modules are completely new to me.
Comment #5
modulo49 CreditAttribution: modulo49 commentedYeah, pretty much completely lost. Here's a sample output from exchange's ical feed. If I understand your function right, I can alter components... but there is no category component to alter.
Comment #6
coredumperror CreditAttribution: coredumperror commentedSorry for the delay! I ended up being super busy all weekend and didn't have a chance to get to this. I'll sit down right now and work up a hook for you.
Comment #7
modulo49 CreditAttribution: modulo49 commentedNo worry about delay, it's very kind of you to supply any kind of help to this degree.
Comment #8
coredumperror CreditAttribution: coredumperror commentedAlright, here's a little one-function custom module that you can install into your Drupal site, which should do what you need. In addition to that, though, you'll need the latest dev release of Date iCal. In looking at your problem, I realized that the right way to solve it was to actually add another hook to Date iCal, which lets modules tweak the final parsed data before it gets sent to Feeds. That's how this custom module does its thing.
Unfortunately, Drupal.org is very slow about creating new Date iCal releases from recent pushes to the git repository. In fact, they appear to have just changed the system, making it far more confusing (it claims that a new dev release from today is already available, but it's actually still serving the old dev release). So you'll either need to wait until tomorrow to download the usual 7.x-3.x-dev release, or you can follow the instructions here to download the latest code from Date iCal's git repo.
Once you've installed both this custom module and the newest Date iCal dev release, clear your site's cache. Then you should be ready to go.
Comment #9
modulo49 CreditAttribution: modulo49 commentedIt works exactly the way it should. Can't thank you enough. I would never have figured that out.
Comment #10
coredumperror CreditAttribution: coredumperror commentedGlad to hear it!
Comment #12
rasmusknabe@gmail.com CreditAttribution: rasmusknabe@gmail.com commentedHi, just found this thread since I'm working on a project where i need to map the X-WR-CALNAME of an imported calendar to a taxonomy term reference on the imported node.
The solution listed here seem to add the calendar name to the CATEGORIES, but i simply need to be able to map the X-WR-CALNAME to a field, and not mix it up with what ever the categories contains.
I need this to be able to sort between different imported calendars in the calender view - is there a way to go about this?
NOTE: I'm unsure if i should ask here or open up a new issue?
Comment #13
coredumperror CreditAttribution: coredumperror commentedPlease do open a new issue. Commenting on an issue that was closed almost 3 years ago is called "necroing", and is highly discouraged.
Comment #14
rasmusknabe@gmail.com CreditAttribution: rasmusknabe@gmail.com commentedSorry about that, I'm not familiar with best practice here.
I'll open a new issue - thanks!