I'd like the calendar to default to Monthly view. How do I accomplish this?
I'd like the calendar to default to Monthly view. How do I accomplish this?
This huge change requires a core hack in ./modules/Calendar/index.php:
Change day to month.PHP Code:55 if ( empty($_REQUEST['view']))
56 {
57 $_REQUEST['view'] = 'day';
58 }
Developers go here
Businesses go there (Dutch)
Modules:
SugarDev.net Developer Tools | Config | Dutch Language Pack
"Nothing gets fixed unless there is a bug"
Is there an upgrade safe way of doing this?
In case this help someone, uploading /modules/Calendar/index.php into /custom/modules/Calendar.index.php seems to work fine and should be "upgarde safe"
Additionaly , editing the table at the end of that file to this will give render your task list in the week view, something I find quite useful.
PHP Code:<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign=top width="70%" style="padding-right: 10px; padding-top: 2px;">
<?php template_calendar($args); ?>
</td>
<?php if ($_REQUEST['view'] == 'day') { ?>
<td valign=top width="30%">
<?php include("modules/Calendar/TasksListView.php") ;?>
</td>
<?php } ?>
<?php if ($_REQUEST['view'] == 'week') { ?>
<td valign=top width="30%">
<?php include("modules/Calendar/TasksListView.php") ;?>
</td>
<?php } ?>
</tr>
</table>
Basically, it renders -or not- an additional cell depending on the requested view.
Regards
Edit:
humm, there´s something (bug? feature?) that makes the task list not to show the tasks with Start Date assigned....
Last edited by HQnet; 2009-05-18 at 12:47 AM.
Hi,
This is an option - from my hacked version of Calmod. Rather than have individual settings, this stores the previous view and date position as a session variable. So once changed, the system will remember what view the user had and whereabouts in the calendar they were. Also, there is a 'reset' link to up it back to the current date. Once the session is closed, it reverts back to the global default view - but it's better changing it once per session rather than for each view.
This is for the v5.1 source code, but it shouldn't have changed for v5.2 - if it has, you'll have to compare the original code and see what needs altering....: Edit modules/Calendar/index.php (or the previously mentioned upgrade-safe version).
At line 47, change:
toCode:if ( empty($_REQUEST['view'])) { $_REQUEST['view'] = 'day'; } $date_arr = array(); if ( isset($_REQUEST['ts'])) { $date_arr['ts'] = $_REQUEST['ts']; } if ( isset($_REQUEST['day'])) { $date_arr['day'] = $_REQUEST['day']; } if ( isset($_REQUEST['month'])) { $date_arr['month'] = $_REQUEST['month']; } if ( isset($_REQUEST['week'])) { $date_arr['week'] = $_REQUEST['week']; } if ( isset($_REQUEST['year'])) { if ($_REQUEST['year'] > 2037 || $_REQUEST['year'] < 1970) { print("Sorry, calendar cannot handle the year you requested"); print("<br>Year must be between 1970 and 2037"); exit; } $date_arr['year'] = $_REQUEST['year']; } // today adjusted for user's timezone if(empty($date_arr)) { global $timedate; $gmt_today = $timedate->get_gmt_db_datetime(); $user_today = $timedate->handle_offset($gmt_today, $GLOBALS['timedate']->get_db_date_time_format()); preg_match('/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/',$user_today,$matches); $date_arr = array( 'year'=>$matches[1], 'month'=>$matches[2], 'day'=>$matches[3], 'hour'=>$matches[4], 'min'=>$matches[5]); } $args['calendar'] = new Calendar($_REQUEST['view'], $date_arr); if ($_REQUEST['view'] == 'day' || $_REQUEST['view'] == 'week' || $_REQUEST['view'] == 'month') { global $current_user; $args['calendar']->add_activities($current_user); } $args['view'] = $_REQUEST['view']; ?>
Code:if (( empty($_REQUEST['view'])) && (empty($_SESSION['view']))) { $_REQUEST['view'] = 'week'; } $date_arr = array(); if ( isset($_SESSION['ts']) && !(isset($_REQUEST['ts']))) { $_REQUEST['ts'] = $_SESSION['ts']; } if ( isset($_SESSION['day']) && !(isset($_REQUEST['day']))) { $_REQUEST['day'] = $_SESSION['day']; } if ( isset($_SESSION['month']) && !(isset($_REQUEST['month']))) { $_REQUEST['month'] = $_SESSION['month']; } if ( isset($_SESSION['week']) && !(isset($_REQUEST['week']))) { $_REQUEST['week'] = $_SESSION['week']; } if ( isset($_SESSION['year']) && !(isset($_REQUEST['year']))) { if ($_SESSION['year'] < 2037 && $_SESSION['year'] > 1970) { $_REQUEST['year'] = $_SESSION['year']; } } if ( isset($_SESSION['view']) && !(isset($_REQUEST['view']))) { $_REQUEST['view'] = $_SESSION['view']; } if ( isset($_REQUEST['ts'])) { $date_arr['ts'] = $_REQUEST['ts']; $_SESSION['ts'] = $_REQUEST['ts']; } if ( isset($_REQUEST['day'])) { $date_arr['day'] = $_REQUEST['day']; $_SESSION['day'] = $_REQUEST['day']; } if ( isset($_REQUEST['month'])) { $date_arr['month'] = $_REQUEST['month']; $_SESSION['month'] = $_REQUEST['month']; } if ( isset($_REQUEST['week'])) { $date_arr['week'] = $_REQUEST['week']; $_SESSION['week'] = $_REQUEST['week']; } if ( isset($_REQUEST['year'])) { if ($_REQUEST['year'] > 2037 || $_REQUEST['year'] < 1970) { print("Sorry, calendar cannot handle the year you requested"); print("<br>Year must be between 1970 and 2037"); exit; } $date_arr['year'] = $_REQUEST['year']; $_SESSION['year'] = $_REQUEST['year']; } if ( isset($_REQUEST['view'])) { $_SESSION['view'] = $_REQUEST['view']; } // today adjusted for user's timezone if(empty($date_arr)|| $_REQUEST['reset'] == 'yes') { global $timedate; if (!($_SESSION['view']=='day' || $_SESSION['view']=='week' ||$_SESSION['view']=='month')) { $_REQUEST['view'] = 'week'; } $gmt_today = $timedate->get_gmt_db_datetime(); $user_today = $timedate->handle_offset($gmt_today, $GLOBALS['timedate']->get_db_date_time_format()); preg_match('/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/',$user_today,$matches); $date_arr = array( 'year'=>$matches[1], 'month'=>$matches[2], 'day'=>$matches[3], 'hour'=>$matches[4], 'min'=>$matches[5]); } $args['calendar'] = new Calendar($_REQUEST['view'], $date_arr); if ($_REQUEST['view'] == 'day' || $_REQUEST['view'] == 'week' || $_REQUEST['view'] == 'month') { global $current_user; $args['calendar']->add_activities($current_user); } $args['view'] = $_REQUEST['view']; ?>
And finally, the last three lines in the same index.php, change:
to:Code:<?php } ?> </tr> </table>
Code:<?php } ?> </tr> <tr><td><br></td></tr> <tr><td scope='row' class="{ROW_COLOR}S1" valign=TOP><slot><a href="./index.php?module=Calendar&action=index&reset=yes" class="listViewTdLinkS1">Reset to today</a></slot></td></tr> </table>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks