0

It looks like the Calendar/Dates modules don't add Views Display types directly. Instead you're apparently supposed to copy one of the default views that come with Calendar to access the additional displays. However, the default views are Node views and I want to create a view of non-nodes. For example, say I want to create an iCal feed display type listing the dates users created their accounts on the site. Is there a way to do that using the Calendar/Date modules?


I made several attempts to use the iCal functionality included with the Calendar module, but in the end I gave up on that idea. Instead, found an issue associated with the Views Bonus Pack, with code for adding iCal support to that module.

I made some modifications to allow me to use arbitrary Views fields in an iCal feed. I'm interested in hearing feedback on the idea, if anyone here gets a chance to try it out.

2

You can do this.

  1. Make calendar module create an extra default view:

    variable_set('calendar_default_view_options', array(
      array('name' => 'calendar'),
      array('name' => 'calendar_custom')
    ));
    

    After clearing cache you should now have two calendar default views which are exactly the same.

  2. Override the custom calendar view.

    hook_views_default_view_alter(&$views) {
      if (isset($views['calendar_custom']) {
        $views['calendar_custom']->base_table = 'users';
      }
    }
    

    You can change the base table of the view, which is what Views will use to determine what you can query from.

Note this is example code and untested, but should work.

  • Okay, that might work, but you'd have to override the calendar-view-ical.tpl.php template file (and probably also its preprocess function) because it makes assumptions about what fields you want to include in the feed: drupalcode.org/project/calendar.git/blob/… For now, I'll stick with my solution because it doesn't require a custom module (to implement hook_views_default_view_alter) or a lot of theme overriding. – Matt V. Jul 28 '11 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.