Projet

Général

Profil

Paste
Télécharger (13,9 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / date_ical / README.txt @ 62e0cc08

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/target to export/import an iCal feed.
6

    
7

    
8
===============================================================================
9
INSTALLATION
10
===============================================================================
11
Date iCal has several required dependencies, and an optional one:
12
- The Views (version 3.5+), Entity API, Libraries API (version 2.0+), and Date
13
  modules are required.
14
- The iCalcreator library v2.20.2 is required; for PHP 7.4 compatibility, use
15
  v2.20.4.
16
- PHP 5.3 is required for the iCalcreator library to properly handle timezones.
17
- The Feeds module is optional. It's needed only if you you wish to import iCal
18
  feeds from other sites.
19

    
20
To install the iCalcreator library, download the project's latest zip file:
21
https://github.com/lkmorlan/iCalcreator/releases
22

    
23
Extract it, and copy iCalcreator.class.php to a folder in your Drupal site
24
named sites/all/libraries/iCalcreator (you'll need to create that folder). Be
25
sure to capitalize the C in iCalcreator.
26

    
27
Or, if you have drush, you can install iCalcreator by running this command from
28
your site's root directory:
29
drush make sites/all/modules/date_ical/date_ical.make --no-core
30

    
31
Then, clear the cache on your site by using either "drush cc all" or logging in
32
to your site and going to Configuration -> Development -> Performance and click
33
the "Clear all caches" button. This is necessary because libraries are cached,
34
and you may see confusing behavior from Date iCal if the iCalcreator library
35
gets cached at a bad time.
36

    
37
To confirm that iCalcreator is installed correctly, log in to your Drupal site
38
and navigate to the admin/reports/status page. If the row titled "Date iCal" is
39
green, Date iCal is ready to go. If it's red, the iCalcreator library is not
40
properly installed. If it's missing, you'll need to enable Date iCal.
41

    
42

    
43
===============================================================================
44
EXPORTING AN ICAL FEED USING Views
45
===============================================================================
46
There are two plugins that export iCal feeds. You can use either one, though
47
the iCal Fields plugin (described later) is a bit more versatile.
48

    
49
HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN
50

    
51
1.  Go to the Manage Display page for the content type you want to export in an
52
    iCal feed. On the "Default" tab, check the box for "iCal" in the section
53
    titled "Use custom display settings for the following view modes", then
54
    click Save.
55
2.  Click the new "iCal" tab that now appears in the upper-right corner of the
56
    Manage Display page for this content type.
57
3.  Set up the iCal view mode to contain whatever should be exported as the
58
    'Description' field for the iCal feed. You can trim the text to the desired
59
    size, include additional information from other fields, etc.
60
4.  Do this for each of the content types that you wish to include in your
61
    site's iCal feeds.
62
5.  Create a new View that displays the entities that you want to include in
63
    the iCal feed.
64
6.  Add a "Feed" display to the same View. Change the Format to "iCal Feed".
65
    When you click "Apply" from that dialog, you'll be given the option to name
66
    the calendar, which will appear in your users' calendar clients as the
67
    calendar's title.
68
7.  Change the Show setting to "iCal Entity".
69
8.  In the settings for iCal Entity, select the date field that should be used
70
    as the event date for the iCal feed. Make sure that you choose a field that
71
    is a part of every entity that your View displays. Otherwise, the entities
72
    which don't have that field will be left out of the iCal feed.
73
9.  You may optionally choose a field that will be used to populate the
74
    Location property of events in your iCal feed. This field can be a text
75
    field, a Node Reference field, an Addressfield, or a Location field.
76
10. Give the Feed a path like 'calendar/%/export.ics', including a '/%/' for
77
    every contextual filter in the view.
78
11. Make sure the Pager options are set to "Display all items".
79
12. Add date filters or arguments that will constrain the view to the items you
80
    want to be included in the iCal feed.
81
13. Using the "Attach to:" setting in the Feed Settings panel, attach the feed
82
    to a another display in the same view (usually a Page display). Be aware,
83
    though, that the Feed will display exactly what its settings tell it to,
84
    regardless of how the Page display is set up. Thus, it's best to ensure
85
    that both displays are configured to include the same content.
86
14. Save the View.
87
15. Navigate to a page which displays the view (usually the Page display's
88
    "path" setting). You should see the iCal icon at the bottom of the view's
89
    output. Clicking on the icon will subscribe your calendar app to the iCal
90
    feed.
91
16. If you don't have a calendar app set up on your computer, or you want your
92
    users to download the ical feed rather than subscribe to it, you'll want to
93
    go back to the View settings page, click the Settings link next to
94
    "Format: iCal Feed", and check "Disable webcal://". Then save your View.
95
    This will make the iCal icon download a .ics file with the events, instead
96
    of loading the events directly into the user's calendar app.
97
17. If events that you expect your feed to include are not appearing when it
98
    gets consumed by a calendar app, check the Drupal permissions for your
99
    event content type. If anonymous users can't view the event nodes, they
100
    won't appear in your feed when it gets loaded by a calendar app.
101

    
102
HOW TO EXPORT AN ICAL FEED USING THE iCal Fields PLUGIN
103
1-6.These steps are the same as above.
104
7.  Add views fields for each piece of information that you want to populate
105
    your iCal feed with. A Date field is required, and fields that will act as
106
    the Title and Description of the events are recommended. You can also
107
    include a Location field.
108
8.  Back in the FORMAT section, change the "Show" setting to 'iCal Fields'.
109
9.  In the settings for iCal Fields, choose which views fields you want to use
110
    for the Date, Title, Description, and Location.
111
10+ These steps are the same as above.
112

    
113

    
114
===============================================================================
115
IMPORTING AN ICAL FEED FROM ANOTHER SITE USING Feeds
116
===============================================================================
117
- Install the Feeds module, which is the framework upon which Date iCal's
118
  import functionality is built.
119
- Login to your Drupal site and navigate to the admin/structure/feeds page.
120
- Click the "Add importer" link, and give it a name and description.
121
- Clicking "Create" will bring you to the general Feeds importer settings page.
122
  This page displays some general information about making Feeds importers,
123
  which you should familiarize yourself with.
124
- In the left sidebar, you'll see "Basic settings", "Fetcher", "Parser", and
125
  "Processor". The Parser and Processor settings are what we're interested in.
126
- In the Parser section, click "change". This will bring up the Parser
127
  selection page, on which you should select the radio button for "iCal Parser"
128
  and then click Save.
129
- Now, under Processor, click the "Settings" link. Most of the time, you'll
130
  want to use the "Update existing nodes (slower than replacing them)" setting.
131
  Then select the Content type of the nodes you'd like to create from iCal
132
  events. You can leave the other settings as their defaults, or change them
133
  as you need. Click Save.
134
- Now click the "Mapping" link at the bottom of the left sidebar. This page is
135
  where you'll define how iCal event properties get mapped into your nodes'
136
  fields. Expand the "Legend" for a detailed description of each source and
137
  target field. Sources are the attributes available in iCal event objects,
138
  and Targets are the fields in your nodes.
139
- Most of this setup is going to be dependent upon how your content type's
140
  fields are configured, but there are some universal requirements:
141
  1) You MUST map the "UID" source to the "GUID" target. Then, after clicking
142
     "Add", click the gear-shaped button that appears in the new table row,
143
     and check the "Unique" checkbox. Then click "Update", and then before
144
     you add any more mappings, click "Save" at the bottom of the page.
145
  2) It's a good idea to map the "Summary/Title" source to the "Title" target,
146
     and the "Description" source to whatever field is the "body" of the node.
147
  3) AS OF 2014/04/10 THERE IS A MAJOR BUG IN Feeds WHICH LEAVES THE DATE
148
     VALUES ON ALL IMPORTED EVENTS BLACNK. YOU MUST APPLY A PATCH TO Feeds
149
     TO FIX THIS PROBLEM. IT IS AVAILABLE HERE: http://drupal.org/node/2237177.
150
- Once you've completed all the mappings, click the "Save" button on the
151
  bottom left side of the page.
152
- Now you can import the iCal feed into nodes by going to the /import page of
153
  your site (e.g. http://www.exmaple.com/import). Click the link for the
154
  importer you just created, and enter the URL of the feed into the "URL"
155
  field. Click the "Import" button, and observe the progress.
156
- Once it's done, you should see a green message saying "Created X nodes." If
157
  you do, you've successfully set up your iCal importer. If you get some other
158
  message, you'll need to tweak the importer's settings.
159

    
160
Remember, you have to map the UID source to the GUID target, and make it
161
unique, or your imports won't work!
162

    
163

    
164
===============================================================================
165
IMPORTANT NOTE ABOUT THE DATE FIELD TIMEZONE SETTING
166
===============================================================================
167
Date fields have a setting called "Time zone handling" which determines how
168
dates are stored in the database, and how they are displayed to users.
169
 - "Site's time zone" converts the date to UTC as it stores it to the DB. Upon
170
  display, it converts the date to the "Default time zone" that's set on your
171
  site's Regional Settings configuration page (/admin/config/regional/settings).
172
 - "Date's time zone" stores the date as it is entered, along with the timezone
173
  name. Upon display, it converts the date from the stored timezone into the
174
  site's default timezone. Well, I'm pretty sure it's *supposed* to do that, but
175
  the code behind this setting is very buggy. DO NOT USE THIS SETTING.
176
 - "User's time zone" converts the date to UTC as it stores it to the DB. Upon
177
  display, it converts the date to the current user's timezone setting.
178
 - "UTC" converts the date to UTC as it stores it to the DB. Upon display, it
179
  performs no conversion, showing the UTC date directly to the user.
180
 - "No time zone conversion" performs no conversion as it stores the date in
181
  the DB. It also performs no conversion upon display.
182

    
183
The appropriate setting to choose here will depend upon how you want times to
184
be displayed on your site. The best setting *would* be "Date's time zone",
185
but since that setting is so buggy, I must recommend against it. Instead,
186
I'd suggest using "Site's time zone" for sites which host events that are
187
mostly in the same timezone (set the site's default timezone appropriately).
188
This works just right for local users of your site, and will be the least
189
confusing for users who live in a different timezone.
190

    
191
For sites which store events that take place in multiple different timezones,
192
the "User's time zone" setting is probably the most appropriate. Most users will
193
presumably be tuning in to your events online or on TV (since many take place
194
far away from them), which means they'll want to know what time the event occurs
195
in their local timezone, so they don't miss the broadcast.
196

    
197
If your Date field is already set to "Date's time zone", you won't be able to
198
change it, because that setting uses a different table schema than the others.
199
Since "Date's time zone" is very buggy, I'd strongly recommend deleting the
200
field and recreating it with a different setting. This will delete all the
201
dates in existing event nodes which use this field.
202

    
203

    
204
===============================================================================
205
HOW TO FIX THE "not a valid timezone" ERROR
206
===============================================================================
207
If you are seeing a warning about invalid timezones when you import an iCal
208
feed, you'll need to implement hook_date_ical_import_timezone_alter() in a
209
custom module to fix it. To do so, either edit an existing custom module, or
210
make a new module and add this function to it:
211

    
212
<?php
213
/**
214
 * Implements hook_date_ical_import_timezone_alter().
215
 */
216
function <module>_date_ical_import_timezone_alter(&$tzid, $context) {
217
  if (!empty($tzid)) {
218
    // Do something to fix your invalid timezone.
219
    // For instance, if all your events take place in one timezone, find your
220
    // region's official TZID, and replace $tzid with it. Like this:
221
    // $tzid = 'America/Los_Angeles';
222
  }
223
}
224
?>
225

    
226
Replace <module> with the name of your module, change the code to do whatever
227
needs to be done to fix your timezones, and clear your Drupal cache.
228

    
229

    
230
===============================================================================
231
ADDITIONAL NOTES
232
===============================================================================
233
Date iCal only supports exporting iCal calendars by using Views.
234
To put an "Add to calendar" button on individual event nodes, try the
235
Add to Cal module (http://drupal.org/project/addtocal), or follow the
236
instructions created by the estimable nmc at:
237
http://nmc-codes.blogspot.ca/2012/11/creating-ical-feed-for-single-node-in.html
238

    
239
The Feeds Tamper module is useful for altering the data in imported iCal feeds.
240

    
241
Developers who wish to implement more powerful manipulation of event data can
242
read the date_ical.api.php file to learn about the various alter hooks that
243
date_ical exposes.
244

    
245
The libraries/windowsZones.json file, which Date iCal uses to map Windows-style
246
timezone names to real timezone IDs, is from Version24 of the Unicode CLDR:
247
http://cldr.unicode.org/.
248

    
249
The author of iCalcreator made extenside backwards incompatible changes to the
250
library in the v2.22 release. Thus Date iCal does not support any version of
251
iCalcreator after v2.20.x.