Results 1 to 6 of 6

Thread: Default Calendar View

  1. #1
    C4talyst is offline Junior Member
    Join Date
    Jan 2009
    Posts
    2

    Default Default Calendar View

    I'd like the calendar to default to Monthly view. How do I accomplish this?

  2. #2
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: Default Calendar View

    This huge change requires a core hack in ./modules/Calendar/index.php:

    PHP Code:
    55    if ( empty($_REQUEST['view']))
    56    {
    57        $_REQUEST['view'] = 'day';
    58    
    Change day to month.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  3. #3
    DigiCRM is offline Senior Member
    Join Date
    Sep 2008
    Posts
    84

    Default Re: Default Calendar View

    Is there an upgrade safe way of doing this?

  4. #4
    HQnet is offline Member
    Join Date
    Mar 2009
    Posts
    12

    Default Re: Default Calendar View

    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.

  5. #5
    Pepin is offline Member
    Join Date
    May 2009
    Posts
    14

    Default Re: Default Calendar View

    Quote Originally Posted by SugarDev.net View Post
    This huge change requires a core hack in ./modules/Calendar/index.php:

    PHP Code:
    55    if ( empty($_REQUEST['view']))
    56    {
    57        $_REQUEST['view'] = 'day';
    58    
    Change day to month.

    Thanks for this. It works!

    However, is it possible to have this modification on a user level. Not many people may want the same view.

    Thanks!

  6. #6
    stevec is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,100

    Default Re: Default Calendar View

    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:

    Code:
    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'];
    
    ?>
    to

    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:

    Code:
    <?php } ?>
    </tr>
    </table>
    to:

    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>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Default view of Calendar
    By ttlinna in forum General Discussion
    Replies: 4
    Last Post: 2006-02-03, 09:22 AM
  2. Replies: 0
    Last Post: 2006-01-14, 04:23 PM
  3. default calendar view
    By scliburn in forum Help
    Replies: 0
    Last Post: 2005-12-30, 08:30 PM
  4. Default Calendar List View
    By JHo in forum General Discussion
    Replies: 0
    Last Post: 2005-07-31, 03:39 AM
  5. Changing default calendar view in Home Page
    By smueller72 in forum Feature Requests
    Replies: 5
    Last Post: 2005-03-03, 04:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •