Hello,

Currently, when I create a calendar view, monthly view will be default view, how can I change it to default weekly view ??

Comments

dydecker’s picture

Status: Active » Fixed

Check 'week' in the setting for Granularity in Argument "Date: Date".

allentseng’s picture

Status: Fixed » Postponed (maintainer needs more info)

Hello dydecker,

I went to my views' argument. I saw "Date: From" and "Date: To". no "Date: Date". and there is no week settings for Granularity after added either "Date: From" or "Date: To" argument. Did I miss something ??

dydecker’s picture

Oh, sorry - I just reread your request was for 5.x-2.0 not 6.2. My mistake. Perhaps someone else could help.

karens’s picture

Title: How to make weekly view as default?? » Options to make week, day, or year the default view
Version: 5.x-2.0-rc2 » 5.x-2.x-dev
Category: support » feature
Status: Postponed (maintainer needs more info) » Active

Defaulting to the month view is hard-coded into the 5.2 version. I fixed that in the 6.2 version but haven't done it in 5.2. This is a feature request, it should be doable. I thought there was already an issue for this, but don't see it now, so I guess this will be it.

allentseng’s picture

Hello Karen,

I have read source code of calendar module. find calendar.inc near line 60 says.
// If no arguments are provided, default to current month view.
if (empty($view->args) || !calendar_is_calendar_arg($view)) {
$query->calendar_type = 'month';

Try to set $query->calendar_type = 'week';
But, not work.

Are there other codes I should change ??
Basically, we need to set all calendar default view to weekly.

masipila’s picture

Hi,

while waiting for the implementation of this feature request this little workaround might be useful.

When you're calendar view is set up and working, add this code to the Argument handling code section of the View:

// Set arguments to current week if no args are set
if (!$args[0]) {
  $y = date('Y');
  $w = date('W');
  $args[0] = $y;
  $args[1] = 'W' . $w;
}
// debugging info, remove these two lines when you're happy with the results
$msg = 'args: ' . $args[0] . ', ' . $args[1];
drupal_set_message($msg);

return $args;

This code simply checks if the Views arguments are empty. In this case it puts the current year to first argument and current week with W-prefix to second argument.

Edit: this makese the week view to be default. This example can be easily modified to make day view the default, just put current year, month and day to the $args array.

Hope this helps,
Markus

allentseng’s picture

Status: Active » Fixed

work like a charm.
thanks Markus.

mroswell’s picture

Status: Fixed » Active

Setting back to active to retain this as a current feature request for the module

karens’s picture

Status: Active » Closed (won't fix)

I've decided I'm not going to add any new features to the D5 version. I need to finish D5 up and get an official release out on D6 and start looking at D7, so there just isn't time to make and maintain more changes to D5.

swortis’s picture

Is there a way of choosing different default views for page vs block (D6)?

Delta Bridges’s picture

Category: feature » support
Status: Closed (won't fix) » Needs review

Hello there,
Although I know this feature will not be ported to the 5.x branch, I will need some help regarding the #6 piece of code kindly provided by masipila.

The code first seemed to work very well when I implemented it last week.
However, one week later, I just realised that the events have not been updated: still the ones from last week.

I cleaned the cache, removed the code, inserted the code again etc... still have last week events listed.

Can anybody help?

Many thanks,

DB

arlinsandbulte’s picture

Any update? Can it be marked won't fix again?

arlinsandbulte’s picture

Status: Needs review » Closed (won't fix)

see #9