Please let me know if you think it is possible to view more than one month at a time with slight modifications to the code, for example:

When viewing a month view, you would scroll down and below that month would be the next month, and so on...

Even if it is not added as a feature, I would like to try to make this work anyway.
Maybe revisit the month view function after incrementing a counter?

CommentFileSizeAuthor
#4 panel1.jpg21.34 KBhaggins
#4 panel2.jpg40.75 KBhaggins
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lowell’s picture

Another option that would help me would be to view more than one week at a time using the same concept.

It will help me to see 8 to 10 weeks of the calendar at a time :-)))

JohnAlbin’s picture

Status: Active » Fixed

With panels, you could load the view into 2 different panels on a page. And with this patch, #243264: Calendar ignore views' argument handling code in month view, you could change the arguments for the 2nd copy of the view.

Or if you want 2 calendar blocks, use the above patch and dupe your view to create a 2nd block.

Status: Fixed » Closed (fixed)

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

haggins’s picture

FileSize
40.75 KB
21.34 KB

I don't know where to start this request...but I think this is the right place since this is exactly what I want to do.

As #2 adviced I'm trying to put the monthly view into a panel. But all I can choose there under "add content" is the calendars block view (attachment 1 "calendar" (btw: what is Calendar Legend? It doesn't show up anything...)). Preview is available as attachment 2.
But how to add the monthly view with additional event information and so on? (?q=calendar)

The second problem is more panel specific but maybe you can tell me in one ore two sentences how to do:
Given the calendar block in a panel I have no way to give it any arguments as the month which should be shown. When clicking on the panel pages operation "Argument settings" it says "the path test has no arguments to configure."

Every advice is welcome!

haggins’s picture

Version: 7.x-1.x-dev » 6.x-2.x-dev
Component: Code » Miscellaneous
Category: feature » support
Status: Closed (fixed) » Active
jenlampton’s picture

@haggins -

You'll need the "views content panes" module (it's part of ctools) to get non-block views into panels.

Unfortunately, it won't help much becuase there's currently no way to change the arguments (?). I'm working on that same thing now. Will post what I find here.

haggins’s picture

got it working. just add i.e. three monthly views to your pane and and set the arguments for the first view to "@0", "@1" for the second etc.

now you can access your pane via "yourpanepath/2009-01/2009-02/2009-3".

haggins’s picture

At least it didn't working with panels for me. See #510234: Using more than 10 arguments does not work

My actual solution is with php-filter:

$amount = 12;
$date_now = substr(date_convert(time(), DATE_UNIX, DATE_ISO, $tz = 'UTC'), 0, 7);
$year_month = explode('-', $date_now);

for($i=1;$i<=$amount;$i++) {
  $view = views_get_view('calendar');
  $view->set_display('calendar_1');

  $view->set_arguments(array($year_month[0].'-'.$year_month[1]));
  print $view->preview();

  $year_month[1]++;
  if($year_month[1] == 13) {
   $year_month[0]++;
   $year_month[1] = 1;
  }
}
Parkes Design’s picture

subscribing

izmeez’s picture

I would like to be able to have a calendar view that is three months. Simply like a one month calendar but that shows three months one after the other. It sounds like you have got that working but I do not understand how you have done that. Can you explain? Is it possible to create or modify a Calendar view to do this?

Thanks,

Izzy

haggins’s picture

Just enable "php filter"-module and create a new page/article. Paste my code above and select "php code" under input format. you can change the amount from 12 to 3 of course ;)

izmeez’s picture

Thanks for the suggestion. I went ahead and tried this by creating a page using php input. It does display a three month calendar but does not display events or other node titles with date fields pertaining to those months. I would like to be able to do this in a similar way to the one month view that comes with the calendar module that also works well with organic groups. I am wondering if I will need to combine your suggestion with a view and then possibly create it as a tab item to work with the other calendar views.

I guess this might be thought of as a feature request because I think a 3-month view would be a very useful addition to the calendar module, especially when one is nearing the end of the month being able to see ahead to the next month is very handy.

Thanks,

Izzy

haggins’s picture

At my testinstallation my solution looks the same as the build in one month view. Maybe you have to edit your views filter? But I don't think so since you say the one month view looks at it should. Have no idea at the moment, sorry.

izmeez’s picture

@haggins, you are absolutely right it works exactly as you say. I didn't realize as only one node was showing at the time I tried your suggestion. Now I see it populated with several node update times.

This is where a view would come in handy to configure as needed. Is that possible?

Thanks,

Izzy

arlinsandbulte’s picture

Status: Active » Fixed

Looks to me like this has been resolved....

izmeez’s picture

Maybe it is not clear what I am thinking and maybe what others might like. Also maybe it would be better to consider it as a feature request.

Yes, the method suggested by @haggins allows to create a 3-month page and it could be modified a bit to show the previous month if it is early in the current month, as follows:

<?php
$amount = 3;
$date_now = substr(date_convert(time(), DATE_UNIX, DATE_ISO, $tz = 'UTC'), 0, 7);
$year_month = explode('-', $date_now);
if($year_month[2] <=15)
  { 
    $year_month[1]--;
    if($year_month[1] == 0)
      { $year_month[0]--;
        $year_month[1] = 12;
      }
  }
for($i=1;$i<=$amount;$i++) 
  {
  $view = views_get_view('calendar');
  $view->set_display('calendar_1');

  $view->set_arguments(array($year_month[0].'-'.$year_month[1]));
  print $view->preview();

  $year_month[1]++;
  if($year_month[1] == 13) 
    { $year_month[0]++;
      $year_month[1] = 1;
    }
  }
?>

But, this is not the same as a view which can be customized to display different content.
I think it would be very useful if the Calendar module included a three month view as there are many circumstances where a one month view is not sufficient, especially when it is near the end of the month.

Is there some way to make this code into a view?

Thanks,

Izzy

P.S. I have not changed the Category or Status of this issue; Maybe I should?

Status: Fixed » Closed (fixed)

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

izmeez’s picture

Category: support » feature
Status: Closed (fixed) » Needs review

I am more than willing to be corrected by others if I should not be doing this, but as explained in #16, rather than letting this item drop I would like to submit this as a feature request.

I think it would be very useful if the calendar module could include a View to display more than one month. This would allow further customization through the view. I cannot figure out how to do this myself and was wondering if anyone else can suggest how to do this.

Thanks,

Izzy

izmeez’s picture

Status: Needs review » Active

Oops, I now see that the array in #16 does not extend to the day of the month.

This works better

<?php
// Set number of months to display
$amount = 3;

$today = getdate();
// To debug, view the array
// print_r($today);

// Date elements now $today[year], $today[mon], $today[mday]
// Start with previous month if today is before the middle of current month

if ($today[mday] <= 15)
  { 
    $today[mon]--;
    if ($today[mon] == 0)
      { $today[year]--;
        $today[mon] = 12;
      }
  }
// Display months, one by one
for ($i=1;$i<=$amount;$i++) 
  {
  $view = views_get_view('calendar');
  $view->set_display('calendar_1');

  $view->set_arguments(array($today[year].'-'.$today[mon]));
  print $view->preview();

  $today[mon]++;
  if ($today[mon] == 13) 
    { $today[year]++;
      $today[mon] = 1;
    }
  }
?>

Unfortunately, neither one works when clicking on previous or next month.

Izzy

rootdownmedia’s picture

+1. Would be nice if it were possible to specify how many months to display within Views settings.

owntheweb’s picture

I'm in agreement with number of months to show and/or what month to start from (maybe relative to beginning of year and/or current day?).

Reason for specifying what month to start from relative to today:
I don't want to start an events focused calendar at the beginning of the year, when the beginning of the year is in the past; of little importance now. This is especially the case if it's the end of the year, and I want people to see what's happening January 5th next year (in my 1 year calendar view).

More food for thought. :)

edit: maybe with the info above I could make a patch? I'm still fuzzy on this stuff but want to contribute (my timing would be incredibly slow though)

Chris97’s picture

I agree that this would be a very useful feature, and I think it could be more generically applicable. In other words, from the Views module, configure the number of days / months / weeks / years, the starting date relative to now (or whatever), and the type of calendar displayed. I envision being able to make just three months of the yearly calendar appear (either horizontally in a page or vertically in a block), those being last month, this month, and next month. Or as others have previously suggested, doing the same thing with the monthly formatting. Similarly, how about the next three weeks displayed in the monthly resolution, or upcoming four days in the weekly view instead of the full seven. Just throwing out ideas. Thanks!

fonant’s picture

This would be most useful for a site I'm developing: display the selected month and the one following it. The solutions above only work for the current date.

If I find a solution I'll post here.

izmeez’s picture

I have been using the code in #19 for some time to simply display 3 months and it has been working fine until today when I made update to Calendar 2.4 and Date 2.7

I am wondering if this may be a simple question and the naming of functions has changed. Any help would be appreciated. The code is duplicated here:

<?php
// Set number of months to display
$amount = 3;

$today = getdate();
// To debug, view the array
// print_r($today);

// Date elements now $today[year], $today[mon], $today[mday]
// Start with previous month if today is before the middle of current month

if ($today[mday] <= 15)
  { 
    $today[mon]--;
    if ($today[mon] == 0)
      { $today[year]--;
        $today[mon] = 12;
      }
  }
// Display months, one by one
for ($i=1;$i<=$amount;$i++) 
  {
  $view = views_get_view('calendar');
  $view->set_display('calendar_1');

  $view->set_arguments(array($today[year].'-'.$today[mon]));
  print $view->preview();

  $today[mon]++;
  if ($today[mon] == 13) 
    { $today[year]++;
      $today[mon] = 1;
    }
  }
?>
izmeez’s picture

In case anyone else is interested, I was able to fix my simple 3 month display using php in a node.

To do this I had to change the line

print $view->preview();

to

print $view->preview('calendar_1');

And I also had to "revert" the calendar view and then re-enable it.

ccrackerjack’s picture

Re #25, Your code works perfectly, thank you very much.

By the way, I deleted "Start with previous month" part since I don't need that "feature". For those that want to display the calendar block instead of page, simply replace 'calendar_1' with 'calendar_block_1' or other views you needed.

buttonwillowsix’s picture

Issue summary: View changes

I am trying to do something similar with multiple weeks. I am trying to implement #24 (after trying many other things!) If anyone has updated code to share that works, that would be great.

apaderno’s picture

Status: Active » Closed (outdated)

I am closing this issue, since it's for a Drupal version no longer supported.