1
|
Date iCal
|
2
|
|
3
|
This module allows users to export iCal feeds using Views, and import iCal feeds
|
4
|
from other sites using Feeds. Any entity that contains a Date field can act as
|
5
|
the source of events for an iCal feed.
|
6
|
|
7
|
===============================================================================
|
8
|
INSTALLATION
|
9
|
===============================================================================
|
10
|
Date iCal has several required dependencies, and an optional one:
|
11
|
- The Views (version 3.5+), Entity API, Libraries API (version 2.0+), and Date
|
12
|
modules are required.
|
13
|
- The iCalcreator library is required.
|
14
|
- PHP 5.3 is required for the iCalcreator library to properly handle timezones.
|
15
|
- The Feeds module is optional. It's needed only if you you wish to import iCal
|
16
|
feeds from other sites.
|
17
|
|
18
|
To install the iCalcreator library, download it from the project's github:
|
19
|
http://github.com/iCalcreator/iCalcreator
|
20
|
Using either git clone or the "Download Zip" button, you'll find the file
|
21
|
iCalcreator.class.php inside. Copy that file to a folder in your Drupal site
|
22
|
named sites/all/libraries/iCalcreator.
|
23
|
|
24
|
Or, if you have drush, install iCalcreator by running this command from your
|
25
|
site's root directory:
|
26
|
drush make sites/all/modules/date_ical/date_ical.make --no-core
|
27
|
|
28
|
Then, clear the cache on your site by using either "drush cc all" or logging in
|
29
|
to your site and going to Configuration -> Development -> Performance and click
|
30
|
the "Clear all caches" button. This is necessary because libraries are cached,
|
31
|
and you may see confusing behavior from Date iCal if the iCalcreator library
|
32
|
gets cached at a bad time.
|
33
|
|
34
|
To confirm that iCalcreator is installed correctly, log in to your Drupal site
|
35
|
and navigate to the admin/reports/status page. If the row titled "Date iCal" is
|
36
|
green, Date iCal is ready to go. If it's red, the iCalcreator library is not
|
37
|
properly installed. If it's missing, you'll need to enable Date iCal.
|
38
|
|
39
|
|
40
|
===============================================================================
|
41
|
EXPORTING AN ICAL FEED USING Views
|
42
|
===============================================================================
|
43
|
There are two plugins that export iCal feeds. You can use either one, though
|
44
|
the iCal Fields plugin (described later) is a bit more versatile.
|
45
|
|
46
|
HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN
|
47
|
|
48
|
1. Go to the Manage Display page for the content type you want to export in an
|
49
|
iCal feed. On the "Default" tab, check the box for "iCal" in the section
|
50
|
titled "Use custom display settings for the following view modes", then
|
51
|
click Save.
|
52
|
2. Click the new "iCal" tab that now appears in the upper-right corner of the
|
53
|
Manage Display page for this content type.
|
54
|
3. Set up the iCal view mode to contain whatever should be exported as the
|
55
|
'Description' field for the iCal feed. You can trim the text to the desired
|
56
|
size, include additional information from other fields, etc.
|
57
|
4. Do this for each of the content types that you wish to include in your
|
58
|
site's iCal feeds.
|
59
|
5. Create a new View that displays the entities that you want to include in the
|
60
|
iCal feed.
|
61
|
6. Add a "Feed" to the view. Change the Format to "iCal Feed". When you click
|
62
|
Apply from that dialog, you'll be given the option to name the calendar,
|
63
|
which will appear in your users' calendar clients as the calendar's title.
|
64
|
7. Change the Show setting to "iCal Entity".
|
65
|
8. In the settings for iCal Entity, select the date field that should be used
|
66
|
as the event date for the iCal feed. Make sure that you choose a field that
|
67
|
is a part of every entity that your View displays. Otherwise, the entities
|
68
|
which don't have that field will be left out of the iCal feed.
|
69
|
9. You may optionally choose a field that will be used to populate the Location
|
70
|
property of events in your iCal feed. This field can be a text field, a
|
71
|
Node Reference field, an Addressfield, or a Location field.
|
72
|
10. Give the feed a path like 'calendar/%/export.ics', including a '/%/' for
|
73
|
every contextual filter in the view.
|
74
|
11. Make sure the Pager options are set to "Display all items".
|
75
|
12. Add date filters or arguments that will constrain the view to the items you
|
76
|
want to be included in the iCal feed.
|
77
|
13. Attach the feed to a another view (usually a Page view that is displaying
|
78
|
the same events). Be aware, though, that attaching the feed to a view with
|
79
|
different output will not make the iCal feed include that output. It will
|
80
|
always include the events which match the feed's filters.
|
81
|
14. Save the View.
|
82
|
15. Navigate to a page which displays the attached view. You should see the iCal
|
83
|
icon at the bottom of the view's output. Clicking on the icon will subscribe
|
84
|
your preferred calendar app to the iCal feed. However, if you don't have a
|
85
|
calendar app set up on your computer, you'll want to go back to the View
|
86
|
settings page, click the Settings link next to "Format: iCal Feed", and check
|
87
|
"Disable webcal://", then save your View. This will make the iCal icon
|
88
|
download a .ics file with the events, instead of loading the events directly
|
89
|
into a calendar app.
|
90
|
|
91
|
HOW TO EXPORT AN ICAL FEED USING THE iCal Fields PLUGIN
|
92
|
1-6.These steps are the same as above.
|
93
|
7. Add views fields for each piece of information that you want to populate
|
94
|
your iCal feed with. A Date field is required, and fields that will act as
|
95
|
the Title and Description of the events are reccomended. You can also
|
96
|
include a Location field.
|
97
|
8. Back in the FORMAT section, change the Show setting to 'iCal Fields'.
|
98
|
9. In the settings for iCal Fields, choose which views fields you want to use
|
99
|
for the Date, Title, Description, and Location.
|
100
|
10+ These steps are the same as above.
|
101
|
|
102
|
|
103
|
===============================================================================
|
104
|
IMPORTING AN ICAL FEED FROM ANOTHER SITE USING Feeds
|
105
|
===============================================================================
|
106
|
- Install the Feeds module, which is the framework upon which Date iCal's
|
107
|
import functionality is built.
|
108
|
- Login to your Drupal site and navigate to the admin/structure/feeds page.
|
109
|
- Click the "Add importer" link, and give it a name and description.
|
110
|
- Clicking "Create" will bring you to the general Feeds importer settings page.
|
111
|
This page displays some general information about making Feeds importers,
|
112
|
which you should familiarize yourself with.
|
113
|
- In the left sidebar, you'll see "Basic settings", "Fetcher", "Parser", and
|
114
|
"Processor". The Parser and Processor settings are what we're interested in.
|
115
|
- In the Parser section, click "change". This will bring up the Parser
|
116
|
selection page, on which you should select the radio button for "iCal Parser"
|
117
|
and then click Save.
|
118
|
- Now, under Processor, click the "Settings" link. Most of the time, you'll
|
119
|
want to use the "Update existing nodes (slower than replacing them)" setting.
|
120
|
Then select the Content type of the nodes you'd like to create from iCal
|
121
|
events. You can leave the other settings as their defeaults, or change them
|
122
|
as you need. Click Save.
|
123
|
- Now click the "Mapping" link at the bottom of the left sidebar. This page is
|
124
|
where you'll define how iCal event properties get mapped into your nodes'
|
125
|
fields. Expand the "Legend" for a detailed description of each source and
|
126
|
target field. Sources are the attributes available in iCal event objects,
|
127
|
and Targets are the fields in your nodes.
|
128
|
- Most of this setup is going to be dependant upon how your content type's
|
129
|
fields are configured, but there are some universal requirements:
|
130
|
1) You MUST map the "UID" source to the "GUID" target. Then, after clicking
|
131
|
"Add", click the gear-shaped button that appears in the new table row,
|
132
|
and check the "Unique" checkbox. Then click "Update", and then before
|
133
|
you add any more mappings, click "Save" at the bottom of the page.
|
134
|
2) It's a good idea to map the "Summary/Title" source to the "Title" target,
|
135
|
and the "Description" source to whatever field is the "body" of the node.
|
136
|
3) As of 2014/02/03 there is a major bug in Feeds that leaves the Date
|
137
|
values on all imported events blank. You must update your Feeds module
|
138
|
to the dev release (https://drupal.org/node/927032) to overcome this bug.
|
139
|
- Once you've completed all the mappings, click the "Save" button on the
|
140
|
bottom left side of the page.
|
141
|
- Now you can import the iCal feed into nodes by going to the /import page of
|
142
|
your site (e.g. http://www.exmaple.com/import). Click the link for the
|
143
|
importer you just created, and enter the URL of the feed you'd like to
|
144
|
import into the "URL" field. Click the "Import" button, and observe the
|
145
|
progress.
|
146
|
- Once it's done, you should see a green message saying "Created X nodes." If
|
147
|
you do, you've successfully set up your iCal importer. If you get some other
|
148
|
message, you'll need to tweak the importer's settings.
|
149
|
|
150
|
Remember, you have to map the UID source to the GUID target, and make it
|
151
|
unique, or your imports won't work!
|
152
|
|
153
|
IMPORTANT NOTE:
|
154
|
If you're building a site that will be viewed by out-of-state users, and you
|
155
|
allow said users to set their own timezone, you'll want to set up your Date
|
156
|
fields to use the "Date's time zone" option. If you don't, then users who live
|
157
|
in a different timezone will be shown the times for your events in their local
|
158
|
timezone, rather than your events' timezone. This makes sense if your events
|
159
|
will be broadcast live to these out-of-state users, but if they need to travel
|
160
|
to your event, they may end up arriving at the wrong time.
|
161
|
|
162
|
===============================================================================
|
163
|
HOW TO FIX THE "not a valid timezone" ERROR
|
164
|
===============================================================================
|
165
|
If you are seeing a warning about invalid timezones when you import an iCal
|
166
|
feed, you'll need to implement hook_date_ical_import_timezone_alter() in a
|
167
|
custom module to fix it. To do so, either edit an existing custom module, or
|
168
|
make a new module and add this function to it:
|
169
|
|
170
|
<?php
|
171
|
/**
|
172
|
* Implements hook_date_ical_import_timezone_alter().
|
173
|
*/
|
174
|
function <module>_date_ical_import_timezone_alter(&$tzid, $context) {
|
175
|
if (!empty($tzid)) {
|
176
|
// Do something to fix your invalid timezone.
|
177
|
// For instance, if all your events take place in one timezone, find your
|
178
|
// region's official TZID, and replace $tzid with it. Like this:
|
179
|
// $tzid = 'America/Los_Angeles';
|
180
|
}
|
181
|
}
|
182
|
?>
|
183
|
|
184
|
Replace <module> with the name of your module, change the code to do whatever
|
185
|
needs to be done to fix your timezones, and clear your Drupal cache.
|
186
|
|
187
|
===============================================================================
|
188
|
ADDITIONAL NOTES
|
189
|
===============================================================================
|
190
|
Date iCal only supports outputting iCal calendars through Views.
|
191
|
To put an "Add to calendar" button on individual event nodes, try the
|
192
|
Add to Cal module (http://drupal.org/project/addtocal), or follow the
|
193
|
instructions created by the estimable nmc at:
|
194
|
http://nmc-codes.blogspot.ca/2012/11/creating-ical-feed-for-single-node-in.html
|
195
|
|
196
|
The Feeds Tamper module is useful for altering the data in imported iCal feeds.
|
197
|
|
198
|
Developers who wish to implement more powerful manipulation of event data can
|
199
|
read the date_ical.api.php file to learn about the various alter hooks that
|
200
|
date_ical exposes.
|
201
|
|
202
|
The libraries/windowsZones.json file, which Date iCal uses to map Windows-style
|
203
|
timezone names to real timezone IDs, is from Version24 of the Unicode CLDR:
|
204
|
http://cldr.unicode.org/.
|