I've been trying to see if there is a way to get Calendar to work with OG such that you can have a different calendar for each group. In principle it seems that it should (and does partially) work.

Here's my process:

1. Created a CCK type called Calendar Event, included a start date/time (with optional end date/time).
2. Created a Group in OG, called Group 1.
3. Created Calendar view (called og_calendar) which uses a filter for "Og: Post in User Subbed Groups" "is equal to" "currently logged in User"
4. Create a Calendar Event and make it published to Group 1 only.
5. Show a Calendar Block on the Group homepage.

Now, if I understand this correctly, I should get:

  • a mini calendar which has the date of my event highlighted (this seems to work OK)
  • when I click on the day of the highlighted event, I should go to the Group page that refers to this node (this doesn't work, it goes to a blank node page
  • if I click on the month link, I should get a large calendar view with group only events for the group page. This sort of works, in that it goes to a month view and my event is visible, but it does not go to a Group page (if I have a different template for the Group, it does not use this template it defaults to the overall site template, so I assume it dropping out of OG)

So, my question/request would be - is there a way to get Calendar to work with OG?

Thanks

ps. here's the Calendar view

  $view = new stdClass();
  $view->name = 'og_calendar';
  $view->description = 'Calendar view of any date field';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'Calendar';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'calendar';
  $view->url = 'og_calendar';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '99';
  $view->block = TRUE;
  $view->block_title = 'Calendar';
  $view->block_header = '';
  $view->block_header_format = '1';
  $view->block_footer = '';
  $view->block_footer_format = '1';
  $view->block_empty = '';
  $view->block_empty_format = '1';
  $view->block_type = 'calendar';
  $view->nodes_per_block = '99';
  $view->block_more = TRUE;
  $view->block_use_page_header = FALSE;
  $view->block_use_page_footer = FALSE;
  $view->block_use_page_empty = FALSE;
  $view->sort = array (
  );
  $view->argument = array (
    array (
      'type' => 'calendar_year',
      'argdefault' => '2',
      'title' => 'Year',
      'options' => '',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
    array (
      'type' => 'calendar_month',
      'argdefault' => '2',
      'title' => 'Month',
      'options' => '',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
    array (
      'type' => 'calendar_day',
      'argdefault' => '2',
      'title' => 'Day',
      'options' => '',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => 'Title:',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
    array (
      'tablename' => 'node_data_field_date_time',
      'field' => 'field_date_time_value',
      'label' => '',
      'handler' => 'content_views_field_handler_ungroup',
      'options' => 'default',
    ),
    array (
      'tablename' => 'node',
      'field' => 'body',
      'label' => '',
      'handler' => 'views_handler_field_body',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'calevent',
),
    ),
    array (
      'tablename' => 'og_uid_node',
      'field' => 'currentuid',
      'operator' => '=',
      'options' => '',
      'value' => '***CURRENT_USER***',
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node, node_data_field_date_time, og_uid_node);
  $views[$view->name] = $view;

Comments

karens’s picture

Category: support » feature

Moshe and Eaton and I have been discussing ways to get this working right to create OG calendars and there may be a few things that need to be tweaked to get it working. I see we don't already have an actual feature request for this, so this will be it :-)

karens’s picture

Oops, not Eaton but Ted Serbinski

mzabala’s picture

I am interested in this as well. What I would love is not just have calendars per organic group, but for a user to view a combined calendar with the events from all the groups they are currently subscribed to.

Veggieryan’s picture

any progress on this front? even with the new "post is in current group" filter this does not work.

Veggieryan’s picture

Any news on this?
Obviously this is an intricate problem... should we just accept that our groups only get list views of events for now? ;)

Are there relevant patches to test and vote on?

thanks!
ryan.

jonhattan’s picture

It does work if the OG group is hardcoded in the view, using the filter "Og: Post in specified group". It raises a:
warning: Invalid argument supplied for foreach() in /var/www/drupal-5.2/includes/form.inc on line 948.

and does not show up the list of available groups. Just enter yourself the nid of the desired group node and it works.

I figure out that the other group filters does not work because when calendar is invoqued outside the group page, the group context info is not available.
The context is available when using the view as a og_ghp_ but is not available if you directly call the view (ej: http://example.com/my_og_calendar). It's neither available if you click to go to another month, etc.

Found this related topic:
http://drupal.org/node/66145

jonhattan’s picture

In fact I made it work with the patch in the topic I mentiones. Enabling a little module that tracks the OG context between pages. It's at:
http://drupal.org/node/66145

The other problem is still not solved (the group theme).
It will be possible to make the big calendar work as the minicalendar, ie: by passing an url argument: ?mini=my_og_calendar/2007/10/all& ??

jason.fisher’s picture

Almost what I'm looking for, but don't believe this quite solves my issue -- trying to get the calendar to show up as a tab for a group using views.

i.e., group is node/61908, trying to get calendar URL to be node/61908/calendar/YYYY/MM/DD -- mainly so I can keep node/61908 as the group home.

It seems your fix works around this problem. I'm thinking I need to fix something in calendar itself?

karens’s picture

I'm not sure this is completely working yet, but I think one thing needed was to be able to use the gid as the first argument and the calendar wasn't properly handling a non-calendar argument in the first position. I just committed a fix to allow that so you should be able to create a calendar url like og/gid/year/month where you substitute in the gid, year, and month in to see the calendar for that group.

I'm not promising that completely works yet, but try it and please report back.

karens’s picture

Not quite working yet. I can get some things working right, but not everything just yet. Still working on this.

karens’s picture

Status: Active » Fixed

I've made some progress on this. Non-calendar args now seem to be working correctly and the latest commit includes a default view for a group calendar that will appear as a tab on the group node page (at node/$arg/calendar). Getting a block view of this working is going to be much more difficult, so I'm going to make a separate issue for that.

kc1981’s picture

Status: Fixed » Active

Thanks for the great work!

This works very well except for that it puts the Calendar tab on any page accessed via http:/example.com/node/xx and not just the group pages. It also addess the Setup and iCal tabs on http://example.com/node

karens’s picture

Status: Active » Fixed

Hmm, you're right. It turns out we need to have OG create a views token that can tell us if this is a valid group. I created a patch for this at http://drupal.org/node/182936. Add that to og.module, then change the url in your view from 'node/$arg/calendar' to 'node/$group/calendar'.

kc1981’s picture

Thanks!

This solves the problem of the Calendar tab showing up, but now when I click on any of the links on a group's Calendar page, the urls read http://example.com/node/$group/calendar/yyyy/mm/dd instead of inserting the group number.

I worked out a fix that involves adding the following function to calendar_api.inc :

function _calendar_og_view_url($url) {
  if ($group_node = og_get_group_context()) {

    // views places the value of $group as the end of the url, get rid of it
    $url = str_replace("/$group_node->nid", "", $url); 

    //replace $group with $gid 
    $url = str_replace("\$group", $group_node->nid, $url);
  }
  return $url;
}

The functions needs to be called in three places to fix the Year Month Day navigation at the top, the prev/next links, and the date links on the monthly calendar.

Around line 299 in calendar.theme I added
$url = _calendar_og_view_url($view->real_url);
and changed the references of $view->real_url to $url for each $calendar_links[]

In calendar_api.inc in calendar_get_calendar(), it should be called on $params['url'] towards the beginning of the function (I put it at line 53).

In calendar.module around line 381, I changed


  $path[$i]     = array(
    'path' => $view->real_url,
    'type' => 'url',
      );

to

  $url = _calendar_og_view_url($view->real_url);
  $path[$i]     = array(
    'path' => $url,
    'type' => 'url',
      );

The links seem to be working now. Hope this helps!

Kevin

karens’s picture

Status: Fixed » Postponed (maintainer needs more info)

I don't think all of that is necessary, I just needed to $group as another arg replacement. I just committed a fix for that. See if that solves the problem (I'm not where I can test it right now).

kc1981’s picture

Is the fix different from the latest versions?

I'm using the latest Calendar 5.x-1-dev and og 5.x-4.0-rc11 (both downloaded this afternoon).

I have Og: Group nid(s) listed as my first argument in the view.

Without the code posted earlier, though, the links on the calendar page for the group point to things like
http://example.com/node/$group/calendar/41/2007/10/12

Did I miss something?

Thanks again. You guys are doing great work on og and calendar!

karens’s picture

When I test this with the latest code I committed and the latest OG, all the internal calendar links, navigation links, etc are fine. It may be you got a Calendar version that didn't have my last commit in it. The only place I can see any problem is in the breadcrumb where I do see '$group' showing up, so I need to investigate that.

karens’s picture

Status: Postponed (maintainer needs more info) » Active

The breadcrumb problem is a Views bug. I submitted a patch at http://drupal.org/node/183191 that gets everything working right.

Leaving this active until Views gets fixed.

kc1981’s picture

The links work fine now with the last night's download and the views patch.

Thanks!

gracearoha’s picture

Wow, Looks like this is moving along quickly. Thanks so much for all the hard work. I have been looking for this function to add to my groups. Just one question: is it necessary to create a new CCK type called Calendar Event or will this new set up work by using the "create event" function already within the og details block?

csc4’s picture

Should this be working now with the current versions of Views, Calendar and OG or do we need to wait for the Views update before trying?

karens’s picture

If you use the latest version of Calendar and the latest development version of OG (not sure the OG fix is in an official release yet) it should work except for the breadcrumbs. The Views fix is to fix the breadcrumbs.

jblackhall’s picture

kc1981’s picture

I think Views needs a similar patch to comment #18 for the views_get_url() function beginning around line 710 in order for the iCal feed to have the proper URL on an OG calendar view. I just posted a comment on http://drupal.org/node/183191, but thought it would be good to reference it here.

gracearoha’s picture

So what is the difference between using this set up and og_calendar?

natalief’s picture

I am also interested in having a user to view a combined calendar with the events from all the groups they are currently subscribed to.

how is this accomplished?

kc1981’s picture

If you don't set the the OG: post in specified group filter on a Calendar view, then it should show items from all the groups a user is subscribed to, plus any site-wide items.

harriska2’s picture

Subscribing (over a year later).

OG_Calendar requires the events module. In this senario, we don't want to use the events calendar but instead use CCK to create the event date (more customized, simpler format, etc).

Remon’s picture

Subscribing

kimadactyl’s picture

I'm getting this problem again. You can manually enter a URL, but the intial link to group calendar doesnt show up anything and the links are in the form:

http://example.com/node/$group/calendar/888/2008/05/all

I'm using 5.x-2.0-rc though, should I make a new ticket?

kimadactyl’s picture

http://drupal.org/node/239594#comment-820846

Works for me now with this patch and the view set to node/$node-group/calendar.

judyschmitz’s picture

Title: Calendar + OG » I would just like to suggest looking at a calender that already does all this : bedeworks?

Here's what I'm trying to do, as an admin to the site, and a user:

Have a global calendar that shows all events
Have an ability to segment that calendar according to separate tracks, or groups (see joomla calendar, it does this)
Have groups be able to post to their associated calendar track.

Is this possible in drupal event/calender/og?

Thanks

Judy

kimadactyl’s picture

I'm not sure what you mean by a "track", but yes I think you can do this Judy, although there are outstanding bugs :)

Kim

bcn’s picture

Title: I would just like to suggest looking at a calender that already does all this : bedeworks? » Calendar + OG

setting Title back...

karens’s picture

Status: Active » Closed (duplicate)

I'm not making changes to the 5.1 version. I'm officially recommending you move to the 5.2 version now. If you have problems in that version you can check for existing issues or add new ones. Feature requests are now getting posted to the D6 version to be back-ported to 5.2.

There are several duplicates of this issue. Handling for this has been changed a lot in 5.2 and there are more current issues to track how that's working.

bryancasler’s picture

subscribe