You are here

README.txt in Date iCal 7.3

Same filename and directory in other branches
  1. 7 README.txt
  2. 7.2 README.txt
Date iCal

This module allows users to export iCal feeds using Views, and import iCal feeds
from other sites using Feeds. Any entity that contains a Date field can act as
the source/target to export/import an iCal feed.


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

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

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

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

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

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


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

HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN

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

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


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

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


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

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

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

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


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

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

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


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

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

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

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

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

File

README.txt
View source
  1. Date iCal
  2. This module allows users to export iCal feeds using Views, and import iCal feeds
  3. from other sites using Feeds. Any entity that contains a Date field can act as
  4. the source/target to export/import an iCal feed.
  5. ===============================================================================
  6. INSTALLATION
  7. ===============================================================================
  8. Date iCal has several required dependencies, and an optional one:
  9. - The Views (version 3.5+), Entity API, Libraries API (version 2.0+), and Date
  10. modules are required.
  11. - The iCalcreator library v2.20.2 is required; for PHP 7.4 compatibility, use
  12. v2.20.4.
  13. - PHP 5.3 is required for the iCalcreator library to properly handle timezones.
  14. - The Feeds module is optional. It's needed only if you you wish to import iCal
  15. feeds from other sites.
  16. To install the iCalcreator library, download the project's latest zip file:
  17. https://github.com/lkmorlan/iCalcreator/releases
  18. Extract it, and copy iCalcreator.class.php to a folder in your Drupal site
  19. named sites/all/libraries/iCalcreator (you'll need to create that folder). Be
  20. sure to capitalize the C in iCalcreator.
  21. Or, if you have drush, you can install iCalcreator by running this command from
  22. your site's root directory:
  23. drush make sites/all/modules/date_ical/date_ical.make --no-core
  24. Then, clear the cache on your site by using either "drush cc all" or logging in
  25. to your site and going to Configuration -> Development -> Performance and click
  26. the "Clear all caches" button. This is necessary because libraries are cached,
  27. and you may see confusing behavior from Date iCal if the iCalcreator library
  28. gets cached at a bad time.
  29. To confirm that iCalcreator is installed correctly, log in to your Drupal site
  30. and navigate to the admin/reports/status page. If the row titled "Date iCal" is
  31. green, Date iCal is ready to go. If it's red, the iCalcreator library is not
  32. properly installed. If it's missing, you'll need to enable Date iCal.
  33. ===============================================================================
  34. EXPORTING AN ICAL FEED USING Views
  35. ===============================================================================
  36. There are two plugins that export iCal feeds. You can use either one, though
  37. the iCal Fields plugin (described later) is a bit more versatile.
  38. HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN
  39. 1. Go to the Manage Display page for the content type you want to export in an
  40. iCal feed. On the "Default" tab, check the box for "iCal" in the section
  41. titled "Use custom display settings for the following view modes", then
  42. click Save.
  43. 2. Click the new "iCal" tab that now appears in the upper-right corner of the
  44. Manage Display page for this content type.
  45. 3. Set up the iCal view mode to contain whatever should be exported as the
  46. 'Description' field for the iCal feed. You can trim the text to the desired
  47. size, include additional information from other fields, etc.
  48. 4. Do this for each of the content types that you wish to include in your
  49. site's iCal feeds.
  50. 5. Create a new View that displays the entities that you want to include in
  51. the iCal feed.
  52. 6. Add a "Feed" display to the same View. Change the Format to "iCal Feed".
  53. When you click "Apply" from that dialog, you'll be given the option to name
  54. the calendar, which will appear in your users' calendar clients as the
  55. calendar's title.
  56. 7. Change the Show setting to "iCal Entity".
  57. 8. In the settings for iCal Entity, select the date field that should be used
  58. as the event date for the iCal feed. Make sure that you choose a field that
  59. is a part of every entity that your View displays. Otherwise, the entities
  60. which don't have that field will be left out of the iCal feed.
  61. 9. You may optionally choose a field that will be used to populate the
  62. Location property of events in your iCal feed. This field can be a text
  63. field, a Node Reference field, an Addressfield, or a Location field.
  64. 10. Give the Feed a path like 'calendar/%/export.ics', including a '/%/' for
  65. every contextual filter in the view.
  66. 11. Make sure the Pager options are set to "Display all items".
  67. 12. Add date filters or arguments that will constrain the view to the items you
  68. want to be included in the iCal feed.
  69. 13. Using the "Attach to:" setting in the Feed Settings panel, attach the feed
  70. to a another display in the same view (usually a Page display). Be aware,
  71. though, that the Feed will display exactly what its settings tell it to,
  72. regardless of how the Page display is set up. Thus, it's best to ensure
  73. that both displays are configured to include the same content.
  74. 14. Save the View.
  75. 15. Navigate to a page which displays the view (usually the Page display's
  76. "path" setting). You should see the iCal icon at the bottom of the view's
  77. output. Clicking on the icon will subscribe your calendar app to the iCal
  78. feed.
  79. 16. If you don't have a calendar app set up on your computer, or you want your
  80. users to download the ical feed rather than subscribe to it, you'll want to
  81. go back to the View settings page, click the Settings link next to
  82. "Format: iCal Feed", and check "Disable webcal://". Then save your View.
  83. This will make the iCal icon download a .ics file with the events, instead
  84. of loading the events directly into the user's calendar app.
  85. 17. If events that you expect your feed to include are not appearing when it
  86. gets consumed by a calendar app, check the Drupal permissions for your
  87. event content type. If anonymous users can't view the event nodes, they
  88. won't appear in your feed when it gets loaded by a calendar app.
  89. HOW TO EXPORT AN ICAL FEED USING THE iCal Fields PLUGIN
  90. 1-6.These steps are the same as above.
  91. 7. Add views fields for each piece of information that you want to populate
  92. your iCal feed with. A Date field is required, and fields that will act as
  93. the Title and Description of the events are recommended. You can also
  94. include a Location field.
  95. 8. Back in the FORMAT section, change the "Show" setting to 'iCal Fields'.
  96. 9. In the settings for iCal Fields, choose which views fields you want to use
  97. for the Date, Title, Description, and Location.
  98. 10+ These steps are the same as above.
  99. ===============================================================================
  100. IMPORTING AN ICAL FEED FROM ANOTHER SITE USING Feeds
  101. ===============================================================================
  102. - Install the Feeds module, which is the framework upon which Date iCal's
  103. import functionality is built.
  104. - Login to your Drupal site and navigate to the admin/structure/feeds page.
  105. - Click the "Add importer" link, and give it a name and description.
  106. - Clicking "Create" will bring you to the general Feeds importer settings page.
  107. This page displays some general information about making Feeds importers,
  108. which you should familiarize yourself with.
  109. - In the left sidebar, you'll see "Basic settings", "Fetcher", "Parser", and
  110. "Processor". The Parser and Processor settings are what we're interested in.
  111. - In the Parser section, click "change". This will bring up the Parser
  112. selection page, on which you should select the radio button for "iCal Parser"
  113. and then click Save.
  114. - Now, under Processor, click the "Settings" link. Most of the time, you'll
  115. want to use the "Update existing nodes (slower than replacing them)" setting.
  116. Then select the Content type of the nodes you'd like to create from iCal
  117. events. You can leave the other settings as their defaults, or change them
  118. as you need. Click Save.
  119. - Now click the "Mapping" link at the bottom of the left sidebar. This page is
  120. where you'll define how iCal event properties get mapped into your nodes'
  121. fields. Expand the "Legend" for a detailed description of each source and
  122. target field. Sources are the attributes available in iCal event objects,
  123. and Targets are the fields in your nodes.
  124. - Most of this setup is going to be dependent upon how your content type's
  125. fields are configured, but there are some universal requirements:
  126. 1) You MUST map the "UID" source to the "GUID" target. Then, after clicking
  127. "Add", click the gear-shaped button that appears in the new table row,
  128. and check the "Unique" checkbox. Then click "Update", and then before
  129. you add any more mappings, click "Save" at the bottom of the page.
  130. 2) It's a good idea to map the "Summary/Title" source to the "Title" target,
  131. and the "Description" source to whatever field is the "body" of the node.
  132. 3) AS OF 2014/04/10 THERE IS A MAJOR BUG IN Feeds WHICH LEAVES THE DATE
  133. VALUES ON ALL IMPORTED EVENTS BLACNK. YOU MUST APPLY A PATCH TO Feeds
  134. TO FIX THIS PROBLEM. IT IS AVAILABLE HERE: http://drupal.org/node/2237177.
  135. - Once you've completed all the mappings, click the "Save" button on the
  136. bottom left side of the page.
  137. - Now you can import the iCal feed into nodes by going to the /import page of
  138. your site (e.g. http://www.exmaple.com/import). Click the link for the
  139. importer you just created, and enter the URL of the feed into the "URL"
  140. field. Click the "Import" button, and observe the progress.
  141. - Once it's done, you should see a green message saying "Created X nodes." If
  142. you do, you've successfully set up your iCal importer. If you get some other
  143. message, you'll need to tweak the importer's settings.
  144. Remember, you have to map the UID source to the GUID target, and make it
  145. unique, or your imports won't work!
  146. ===============================================================================
  147. IMPORTANT NOTE ABOUT THE DATE FIELD TIMEZONE SETTING
  148. ===============================================================================
  149. Date fields have a setting called "Time zone handling" which determines how
  150. dates are stored in the database, and how they are displayed to users.
  151. - "Site's time zone" converts the date to UTC as it stores it to the DB. Upon
  152. display, it converts the date to the "Default time zone" that's set on your
  153. site's Regional Settings configuration page (/admin/config/regional/settings).
  154. - "Date's time zone" stores the date as it is entered, along with the timezone
  155. name. Upon display, it converts the date from the stored timezone into the
  156. site's default timezone. Well, I'm pretty sure it's *supposed* to do that, but
  157. the code behind this setting is very buggy. DO NOT USE THIS SETTING.
  158. - "User's time zone" converts the date to UTC as it stores it to the DB. Upon
  159. display, it converts the date to the current user's timezone setting.
  160. - "UTC" converts the date to UTC as it stores it to the DB. Upon display, it
  161. performs no conversion, showing the UTC date directly to the user.
  162. - "No time zone conversion" performs no conversion as it stores the date in
  163. the DB. It also performs no conversion upon display.
  164. The appropriate setting to choose here will depend upon how you want times to
  165. be displayed on your site. The best setting *would* be "Date's time zone",
  166. but since that setting is so buggy, I must recommend against it. Instead,
  167. I'd suggest using "Site's time zone" for sites which host events that are
  168. mostly in the same timezone (set the site's default timezone appropriately).
  169. This works just right for local users of your site, and will be the least
  170. confusing for users who live in a different timezone.
  171. For sites which store events that take place in multiple different timezones,
  172. the "User's time zone" setting is probably the most appropriate. Most users will
  173. presumably be tuning in to your events online or on TV (since many take place
  174. far away from them), which means they'll want to know what time the event occurs
  175. in their local timezone, so they don't miss the broadcast.
  176. If your Date field is already set to "Date's time zone", you won't be able to
  177. change it, because that setting uses a different table schema than the others.
  178. Since "Date's time zone" is very buggy, I'd strongly recommend deleting the
  179. field and recreating it with a different setting. This will delete all the
  180. dates in existing event nodes which use this field.
  181. ===============================================================================
  182. HOW TO FIX THE "not a valid timezone" ERROR
  183. ===============================================================================
  184. If you are seeing a warning about invalid timezones when you import an iCal
  185. feed, you'll need to implement hook_date_ical_import_timezone_alter() in a
  186. custom module to fix it. To do so, either edit an existing custom module, or
  187. make a new module and add this function to it:
  188. /**
  189. * Implements hook_date_ical_import_timezone_alter().
  190. */
  191. function _date_ical_import_timezone_alter(&$tzid, $context) {
  192. if (!empty($tzid)) {
  193. // Do something to fix your invalid timezone.
  194. // For instance, if all your events take place in one timezone, find your
  195. // region's official TZID, and replace $tzid with it. Like this:
  196. // $tzid = 'America/Los_Angeles';
  197. }
  198. }
  199. ?>
  200. Replace with the name of your module, change the code to do whatever
  201. needs to be done to fix your timezones, and clear your Drupal cache.
  202. ===============================================================================
  203. ADDITIONAL NOTES
  204. ===============================================================================
  205. Date iCal only supports exporting iCal calendars by using Views.
  206. To put an "Add to calendar" button on individual event nodes, try the
  207. Add to Cal module (http://drupal.org/project/addtocal), or follow the
  208. instructions created by the estimable nmc at:
  209. http://nmc-codes.blogspot.ca/2012/11/creating-ical-feed-for-single-node-in.html
  210. The Feeds Tamper module is useful for altering the data in imported iCal feeds.
  211. Developers who wish to implement more powerful manipulation of event data can
  212. read the date_ical.api.php file to learn about the various alter hooks that
  213. date_ical exposes.
  214. The libraries/windowsZones.json file, which Date iCal uses to map Windows-style
  215. timezone names to real timezone IDs, is from Version24 of the Unicode CLDR:
  216. http://cldr.unicode.org/.
  217. The author of iCalcreator made extenside backwards incompatible changes to the
  218. library in the v2.22 release. Thus Date iCal does not support any version of
  219. iCalcreator after v2.20.x.