Last updated 21 June 2013. Created on 2 September 2011.
Edited by mohit_aghera, edvanleeuwen, arlinsandbulte, KarenS. Log in to edit this page.

There have been lots of questions about how to create a calendar for an Organic Group that is limited to displaying only events for a single group. This can be done by creating a calendar in the normal way. Then, once it is working correctly for all content, add an Organic Groups contextual filter to each display, right before the date contextual filter. It will not be immediately obvious how to do that, so here is how:

1) Be sure to enable the Organic Groups Context module (it comes as a part of the Organic Groups package). This is needed to provide a method we can use to deduce which group should be displayed.

2) Edit the calendar view. Add a relationship to the view for "Group membership: Node group membership ".

For 7.x-2.0:
Add a relationship to the view for "OG membership: Group Node from OG membership".(The Node group that is associated with the OG membership.)

3) Add a new contextual filter to each display. You will need "OG membership: Group gid ". Where it says "When the filter value is NOT in the URL" choose the option to add a default value and select the option "Current group from context".

For 7.x-2.0:
You will need "OG membership: Group ID" ("Og membership "gid" property"). Where it says "When the filter value is NOT available" choose the option "Provide default value" and select the option "Current OG group from context".

4) Re-arrange the contextual filters so that the OG filter is before the date filter.

5) To see the calendar as a 'Calendar' tab on the Group node, change the path to 'node/%/calendar' and set it up to be a Menu tab with the name of 'Calendar'. When you view the group node you should see the tab, which in turn should show you the calendar.

You can play around with other options for altering the path to inject the GID where it can be deduced from where you are on the site. If you want to test this in the preview by typing in a GID as the argument, note that we are looking for the GID, which in Drupal 7 is NOT the same as the group NID.

Looking for support? Visit the forums, or join #drupal-support in IRC.


jlab’s picture

How would Panels fit in with this equation? Now that Organic Groups is pushed to Panels integration how would you display this calendar in the Group Panel Page?

I have been given the task to create a Group Event Calendar in Drupal 7. In Drupal 6 I would have accomplished this easily with OG, Context and Spaces modules.

But my attempts to create something similar in Drupal 7 ends up a ghastly abortion.

The above solution seems to work outside the Panels paradigm. Is there a way that the calendar could be displayed inside the panel page instead as a menu tab?

arosboro’s picture

personxx, try using spaces_og and features to enable your calendar. You'll need the filter 'Spaces: Content in current space (True)' and maybe the Spaces Feature Page Access setting. Other than that I followed this tutorial. Your feature will appear in the features menu when enabled. You may also want to get og_create_perms and the patch in its issue queue for og that limits the OG Create Content Links block to only show content types which the user has permission to create.

andyp9260’s picture

I finally had some success with this problem myself though still not exactly what I want yet, it at least works now. I followed steps 1-4 given by KarenS see ( but instead of adding the tab for the calendar on step 5, in panels, I created content in the region I wanted and added the OG calendar view created previously. I changed the view from the default of master to month, I preferred the block view however I havent had success with that yet.

miromarchi’s picture

Did you succeed in setting up Group calendar with panels? If you did could you share the howto? Thanks

Miro Marchi

joverstreet’s picture

This is very helpful if you want to make sure the user can only see the groups they're allowed to, but what if you want them to be able to see all groups as well as a subset? We have a need for someone to use the exposed filters to show which events they wish to view for specific combinations of groups. The Better Exposed Filters module is very helpful, but I can't seem to get the group names/audience to show for the filtering. The only choices are the gid, the delta, and whether or not it's group content. Am I missing a relationship somewhere? How can I have it filter by user-chosen organic group name?

I've found other people asking the same question online (, but no answers.


wiherek’s picture

that includes a views search option. I don't even see the og search block in views...
anyway, i'd like to be able to create a custom search for OG... I now managed to list all the nodes in a block, but I don't see the selection filters that I set up as exposed.

nicodv’s picture

Hi there, I followed every step but my view is filtering by nid not by gid, so the calendar shows the wrong content in the inadequate group calendar. I've been scratching my head for a day and a half but at the end, the only combination of relationship and contextual filter that makes sense is the one posted by Karen, so, what can it be happening here?

relationships: OG membership: OG membership from Node
contextual filters: (OG membership from node) OG membership: OG group gid

Thanks in advance, my project is only missing this calendar thing and is over :P



ZetaTrooper’s picture

I follow the steps exactly as outlined above and everything goes fine until step 3 - when I try to save the Contextual Filter I get an error message in the top of the Contextual Filters window: "An illegal choice has been detected. Please contact the site administrator."

I then move this Contextual Filter above the Date Filter as specified, but then the calendar view vanishes completely.

I would be tremendously grateful for any help resolving this problem. Thanks!

ZetaTrooper’s picture

The illegal choice issue I was getting was being caused by the beta version of the Flag module I had installed. See:

However, even when I got this error message resolved, the contextual filter appears to be applied but all my events disappear. I thought this was supposed to filter to show just events that are in my group, but it makes everything disappear.

hannes1234’s picture

my calender shows only the dates that are posted in those groups that the user subscribed - perfekt!
But what is need to be done if i want to have dates from other contents (contents which are not in the groups) in the same calender?
I tried to rearrange the contextual filter, but it didn't make a difference.
Is it possible to show a second overlay on the Calender?

thanks for help

CarlHinton’s picture

The way I eventually got this to work was to create a bespoke views handler and filter by the result 1/0


class mypage_special extends views_handler_field_numeric {
  function option_definition() {
    $options = parent::option_definition();
    return $options;

  function render($values) {

    $arg = (int) arg(1);

    $gid = db_select('og', 'o')
    ->fields('o', array('gid', 'etid'))
    ->condition('etid', $arg,'=')

    $gid = $gid['gid'];

    $lookup = db_select('og_membership', 'om')
    ->fields('om', array('id', 'etid', 'gid'))
    ->condition('etid', $values->nid,'=')
    ->condition('gid', $gid,'=')

    $lookup = $lookup['id'];

    if ($lookup == FALSE) {
      return 0;
    else {
      return 1;


  function query() { }
function mypage_views_data() {

// Our fields
$data['node']['og-display'] = array(
    'title' => t('OG-Display'),
    'help' => t('Is this node in the OG connected to the node in arg 1.'),

// Adds our field in the "Fields" section of Views
$data['node']['og-display']['field'] = array(
    'handler' => 'mypage_special',
    'click sortable' => TRUE,

// Adds our field in the "Filters" section of Views
$data['node']['og-display']['filter'] = array(
    'handler' => 'views_handler_filter_numeric',

return $data;

This is really horrible and 'hacky' - but it worked

gittosj’s picture

I'd been wrestling with this for some time and the parent post by Karen S worked perfectly - Thank you, much appreciated & thanks for all you work on calendar - you're a pro

leoklein’s picture

I was wondering how in the world to make a calendar with OG 7.2. Thanks!

(Now if I could only figure out how to add breadcrumbs to the mix...)

yutaolife’s picture

I am facing a issue about that og calendar. I reference the D7 og calendar( And now, the calendar display under the group is correctly. But, the data(or, we can say event not display in calendar). Would you please tell me that how to fixed it?

cfuller12’s picture

This method no longer works as documented with the latest OG update. OG has changed contextual filters to be based on etid (entity id), instead of gid (group id), so it doesn't appear to be possible to do this any longer without writing code. The simplest fix I found was to make a small change to the query using hook_views_query_alter. To do this, follow the instructions above with two notable changes:

  • OG membership: Group gid is now OG membership: Entity id and
  • Group membership: Node group membership is now OG membership: OG membership from Node

Next, create a file called in an existing (or new) custom module directory. Add the following code:

function MODULENAME_views_query_alter(&$view, &$query) {
  if ($view->name == 'bucharest_calendar') {
    $query->where[0]['conditions'][1]['field'] = 'og_membership_node.gid = :og_membership_etid';

This will force the view to filter by the id of the group instead of the id of an individual node belonging to the group.

barry6575’s picture

Does this still work? I tried using the code but was unsuccessful. I could be doing something wrong.

Cookie.Monster’s picture

This didn't work for me either. I also could be doing something wrong. I see the calendar tab in the group and can view the calendar. It just doesn't show the events for the group.

barry6575’s picture

It is now working for me. I took another crack at the directions and it works like a charm. I believe that I initially did not set the GID (provide default settings) to the proper context that was needed.

kundanrai’s picture

Thank you, this was what I was looking for!!!

mark_anthony’s picture

I have set Month Path to be: /node/%/calendar
and Menu to be:
Type: Menu tab
Title: Calendar - Month
Menu: Navigation

But, I am getting the tabs on all nodes : View, Calendar - month
Not just on the Group nodes like I want?

Where is my error? In a Relationship?

griz’s picture

If anyone else has this problem: the answer is to set validation criteria on the GID contextual filter. Choose "Organic groups" and if the argument doesn't validate the response should be 404 - page not found. I did that for all of my OG calendar displays and the tab now only shows on group nodes (where said arg validates correctly as a GID).

griz’s picture

I hit the right reply button, but after logging in apparently that doesn't count :/