Hi all

I'd appreciate any advice or pointers regarding the best way to use Calendar in panels.

I'm using the dev version of Calendar and the other modules. It seems to work quite well, thanks. I needed to install the patch in another thread to get the Month Week Day Year links to appear.

I want to use Calendar in Panels. There will be multiple calendars in different sections of the site with events filtered by a taxonomy term. I don't want the users to choose this term. I want them to simply see the correct events related to that section of the site. It seems like the best way to do that is to create a content pane display for the Calender view and display it in a panel. The panel will pass in the term id as an argument to the contextual filter in the view. There will be other panels with other content on the page.

I have this mostly working but there are a few problems. The Month / Week / Day / Year links don't appear. They would be kind of meaningless anyway because I've only exposed a single content pane displaying the month. I think a way to make this work is to create content pane displays for the four different formats, add them all to the panel and use the panel visibility rules to determine which to show. Then I think I'd need to create my own links in another panel which sends in another argument. Another problem is that the links on each day in the calendar go to the original view and not to the panel. I might need to override and edit a template to fix that.

I'm really just hoping that someone who has been down the same path might be able to validate what I'm doing or suggest a better way.

Thanks
Ross

Comments

icosa’s picture

Issue summary: View changes

Added the final line about misspelling.

icosa’s picture

Title: Calender in Panels. Looking for ideas and advice. » Calendar in Panels. Looking for ideas and advice.

Correcting title typo.

revelstokesnowboard’s picture

Hey Ross, it sounds to me like you're on the right track. I'm trying to do something similar with a date.

I am encountering a similar (the same?) problem with the Next and Back buttons leading to the original calendar view. I would think it is solvable with Panels; create a new panel with exactly the same content, but pass in a different arg. Possibly from the URL?

Keep me posted on how this pans out; I'd love to know. I'm trying to find some documentation on using Calendar with Panels but it seems non-existant..

BrightBold’s picture

Hmm... I'm having somewhat different problems. Maybe we can help each other out. Here's what I did:

  • In Views, created a Calendar Pane display.
  • Under Pane Settings, set Use Panel Path to Yes (I think this will help solve your problem, @revelstokesnowboard - that setting redirects links to panels rather than views).
  • For Argument Input, I set all my arguments to have "from Panel argument" as the source and chose the appropriate URL position for each. (My URL is project/gid/calendar/date, where gid is the Organic Groups group ID, and date is the year and month for Calendar, so in theory the argument positions should be second and fourth, respectively.
  • Then, I went into each of the attachment views (Year, Month, Week, etc.) and added "Calendar Pane" to the "Attach to" options.

But here's where I run into problems. When you click any link, the two arguments are suddenly appended to the URL. So when I click the Next button, project/3/calendar becomes project/3/calendar/3/2011-12. So in the view I have to set the date argument to fifth instead of fourth. But the calendar doesn't actually change from November on the initial click. Then when I click Next a second time, I get project/3/2011-12/3/2011-12 and the calendar changes to December. An additional click gets me project/3/2011-12/3/2011-12/3/2012-01 and January. Aargh!

So the reason the links don't work on first click is because there's not initially a date argument in the URL. If I can include the current year and month in the initial URL, at least everything will work, but if anyone knows how to fix the eternally growing URL I'd love to hear it!

revelstokesnowboard’s picture

Yeah I ran into this problem earlier.

You need to clone the out of the box "calendar" view and attach one of either "Year" "Month" "Week" or "Day" views to your panel view. You do this with the "Attach to" setting in views, in my case, I attached the Month view to my panel.

I can't remember exactly what solved the appended argument in the URL; but I think it was attaching the Month view to my panel - it's just a configuration problem in any case, not a bug.

In addition to, as you mentioned earlier, setting argument input and "Use Panel Path: YES", you also might want to try to configure you panel views "Allow Settings" to allow "Path Override" . Then in Panels override your calendars page to the page you're displaying it on.

http://drupal.org/node/423492#comment-4779352

That's where I found my solution. Rather lengthy thread..

BrightBold’s picture

Thanks for the link. I did already have the views attached (maybe that part of your instructions was directed at @icosa) but I didn't have the Allow Settings set to Path Override. When I make that change, it fixes the appending path problem but there's something wrong with the way I have the paths configured, because now clicking the Next link takes me out of panels and to the regular View page (even thought I have Use Panel Path: Yes.)

Based on my reading of the other thread, I have both the panel page and the view page URL set to the same thing, but if I set the view URL to something else (I had it set to blah/blah/calendarX at first so it wouldn't conflict with the panel page URL, but links still directed there.) Since you seem to have it working successfully, do you have any thoughts about where I may have gone wrong?

revelstokesnowboard’s picture

@BrightBold

What I did in the end (took some trial and error to get this working) was to create a Page node instead of Panel node (which I'm assuming you did), and use Panels selection rules set to node/445. This would work with a Node Alias too I assume.

Then you can have your view path set to whatever you like if you need to display that calendar on its own page at full size, or whatever.

Hope this helps dude, LMK.

revelstokesnowboard’s picture

OHH RIGHT. The reason doing that (using a Page node vs. Panel node) is necessary is so that you can actually take advantage of the setting "Allow Settings set to Path Override" in Views. I couldn't find a way to actually set the path-override having created a Panel node, which directs links created by the view to the panel URL.

If what I'm saying doesn't make any sense, or is wrong for that matter, let me know; this is more-or-less the first time I've tried to explain anything drupal-related to anyone. :)

KarenS’s picture

Status: Active » Fixed

The year/month/day links only work for displays that have paths, which panel panes do not. So they won't work (and wouldn't make sense anyway in a panel). If you're attaching multiple versions of calendar displays to your view you'll likely get odd results. I would not attempt that. Keep the view simple, one display each for day, month, week, year.

BrightBold’s picture

Karen does this mean the previous/next links won't work with Panels either? I'm trying to get a calendar for Organic Groups, which I'm sure has been done before, but I'm having trouble getting it to work.

BrightBold’s picture

Update for anyone else with this problem:

Despite the fact that other people seem to have this working in a Views Pane per #423492: Calender Navigation not working on Panels due to problem with date_real_url(), I couldn't ever get this working with a pane. Possibly because of the dual argument problem as mentioned in #1399964: Calendar tabs not providing correct links when other contextual filters used?

So using @revelstokesnowboard's solution of using a Views Page and setting the Panel path to project/%gid/calendar while setting the Views path to something else (otherwise when you click the Prev/Next links you'll leave the panel context) worked. In the panel content settings I used "Group" for the OG membership: Group gid context and "No context" for Date. I checked the box for Send arguments and set Override URL to project/%/calendar.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nedjo’s picture

Issue tags: +FAQ

I closed a couple of support requests as duplicates, so adding FAQ tag.

dunx’s picture

There seems to be no "recipe" for getting Calendar within Panels. I had no end of problems that didn't really make sense as creating identical panels seemed to produce different results, which all seemed to stem from some sort of path confusion. Anyway, the final problem I was left with was the ever-expanding url issue noted in #3 above.

I solved that by using:

function mymod_url_outbound_alter(&$path, &$options, $original_path) {

  $bits=explode('/',$path);
  if ( $bits[0] == 'events' && $bits[2] ) {
    $path='events/' . $bits[1];
  }
}

That gets rid of the extra bit of the URL before it's removed. Might be more efficient with a preg_replace, but above works for me.

dunx’s picture

Issue summary: View changes

Realized I could change the title.