RSS

LuxCal Forum

The place for questions, suggestions and news about the LuxCal Event Calendar

User:   Password:   Remember Me?   
LuxCal Forum / General / Support / always show todays date on startup
Posted:  24 Apr 2011 13:46
When I navigate to the calendar from my website I initially show month view.
It would be desirable to always initially show the current date/month.
Currently if you navigate to the calendar, view a different month, and then navigate away from the calendar and then navigate back to the calendar it still remembers the previous month.

If I am not clear, stated another way when I click on my calendar link I always want the current month to show initially. Currently it remembers the last month shown.

this web site has been set up do do this:

http://www.cristinatejeda.com/test_DB/index.php

What is the easiest way to make this change? Seems like a basic question, but sorry, I could not find this info anywhere on the forum.

Great product. Would be nice to edit individual repeating events as stated in many posts. Seems the easiest way to do that would be to have as an option whether the events stay lumped together or if they are generated as separate individual events. Obviously it would be very cumbersome if someone generated numerous separate events, but conceptually that is really not a repeating event and thus they probably do not really want to do that anyways. So you could have a warning if someone is trying to generate a large amount (pick threshold) of separate events.

j smick
Posted:  25 Apr 2011 19:16
Hi,
To implement what you are asking, a minor change will be needed in the index.php file.
From the www.cristinatejeda.com web site I saw that you are using LuxCal V1.8, which is a rather old version.
Before I give you a solution to your question, please let me know if you really want to stay with LuxCal version 1.8 (I would recommend to upgrade to V2.4)
For V1.8 the solution will be slightly different from V2.4.
Roel
Posted:  26 Apr 2011 01:33
I am using version 2.4.
That link to cristinatejeda..com was only used as an example of the behavior I am looking for.

thanks,
jim
Posted:  26 Apr 2011 09:52   Last Edited By: Roel B.
Hi Jim,
For LuxCal version 2.4.
To always initially show the current date, change the file index.php as follows:
Replace lines 107 - 109 (just below the text "//set current date") by the following line:

  $_SESSION['cD'] = date("Y-m-d");

That should do it.
Roel
Posted:  27 Apr 2011 16:57
I can now see that will do exactly as I requested. Thank you.
Another issue came up in that whenever the event view was selected I wanted to start from current date as well. That is needed to insure the expected future events are all listed. To solve all these issues I wrote a small PHP script. I hope this helps someone. Thanks for the great product.

jim
<?php
// expects two url parameters:
// v with legal values: 1 for year, 2 for month and 5 for event. This param will be passed on to calendar as cP
// scd with legal values: 0 for false and 1 for true. This instructs calendar to set the date to current date.
//             This will be passed on to calendar as cD
// so sample valid link to this calendar page should look like: http://yourdomain.com/calviews?v=2&scd=1  for month view set to current date
// as 'output' three PHP strings are generated to be used in HTML part of document
// 1)  $ostr contains iframe HTML  2) $ohdr contains correct header string based on calendar type
// 3)  $olist contains list of menu items to select which calendar view you want
// the generated HTML iframe command will look like:
// <iframe class="luxCal" src="../zzcalendar/luxcal240/?hdr=0&cP=2&cD=2011-04-24" width="770px" height="860px"></iframe>.
$view = $_GET['v'];            // calendar view 1 for year, 2 for month, 5 for events
$scday = $_GET['scd'];    // set to current day  1 for set to current day, otherwise do nothing
$wfr = "770px";                    // width iframe
$hfr = "860px";                    // height iframe
$ssrc = "../zzcalendar/luxcal240/";        // src iframe. Needs to be changed for your environment. This is folder where luxcal program is located on your server.
$ostr = '<iframe class="luxCal" src="' . $ssrc . '?hdr=0&cP=';        // output string for start of iframe -for my use, the calendar will not show header
$oline1 = '<option value="../calviews/?v=2&scd=0">Month</option>' . "<br />"; //3 lines in select menu view picker
$oline2 = '<option value="../calviews/?v=1&scd=0">Year</option>' . "<br/>";
$oline3 = '<option value="../calviews/?v=5&scd=1">Events</option>' . "<br/>";
switch ($view) {
    case 1:
        $ohdr = "Year View" . "<br />";
        $oline2 = str_replace('">', '" selected>', $oline2);    //select correct menu item
        break;
    case 5:
        $ohdr = "Future Events" . "<br/>" . "(3 months)";
        $oline3 = str_replace('">', '" selected>', $oline3);    //select correct menu item
        break;
    case 2:
    default:
        $view = 2;        // catch basket for default - coerce to month view
        $ohdr = "Month View" . "<br/>";
        $oline1 = str_replace('">', '" selected>', $oline1);    //select correct menu item
}
$ostr = $ostr . $view;
if ($scday == 1) {
    $ostr = $ostr . "&cD=" . date("Y-m-d");
}
$ostr = $ostr . '" width="' . $wfr . '" height="' . $hfr . '"></iframe>';
$olist = $oline1 . $oline2 . $oline3;
?>

<!-- sample HTML -->
<?echo $ostr, "<br />";?>
<div align = center>
<h1>
<?echo $ohdr, "<br />";?>
Calendar
</h1>
<form name="jump">
<select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">
<?echo $olist; ?>
</select>
</form>
</div>
/c]
Posted:  09 May 2011 15:21
Another way that keeps options open is to add cD = 0 value which would set the cD to todays date. I modified your code in index.php slightly to accommodate this. It seems like this might be a popular option to incorporate for future updates.

//set current date
if (isset($_REQUEST['newD'])) { $_SESSION['cD'] = DDtoID($_REQUEST['newD']); }
elseif (isset($_REQUEST['cD'])) {
    $cdparam = $_REQUEST['cD'];
    if ($cdparam == 0) $cdparam = date("Y-m-d");
    $_SESSION['cD'] = $cdparam;
}
elseif (empty($_SESSION['cD'])) { $_SESSION['cD'] = date("Y-m-d"); }

Posted:  12 May 2011 19:36   Last Edited By: acae
I tried to implement Roel's code change and it works, kind of.

It always sets the date to todays date. However it doesn't allow the date to be changed when viewing month/week/today etc. No matter what you select it reverts back to today's date. 

Maybe I'm doing something wrong. Also, I don't mean to sound picky but are you certain it's lines 107-109? I have no idea why but with the original code, the calendar always reverts to 25/04/2011 (only test for a few days, but so far it's always the same date).

I'm not hassling anyone about, I think the calendar is great. Just thought you'd maybe want to know. Thanks again.:)thump_up
Posted:  12 May 2011 22:27
Oops, yes you are right, the code change I suggested has as side effect that the user can't change the date anymore. This is bad.
And the lines are wrong as well; it should be lines 104-106 for LuxCal 2.4.0.

If I could distinguish when the calendar is initially called from subsequent navigation calls, I could post a "working" code change.
However, I don't know yet how to find out. Ok, adding a parameter to the URL is a possibility (e.g. www.mysite.com/calendar/?today=1), but I don't like this.

I will try to find a solution.
Roel
Posted:  13 May 2011 04:53   Last Edited By: acae
Hmm I have an idea but not having programmed for over a decade it's probably incorrect.

Could it be implemented by having two values? One variable called something like initialdate (this is always the starting point for the calendar view and is the date of the current day much like the code above) and a second value for something like inputdate (a value entered by the user).

An IF statement to say

IF inputdate = null then
calendardate= initialdate
else
calendardate= inputdate, inputdate=null;

That way it always resets the inputdate to null for the next calendar view. Oh and btw I know that's not actual code. :D so don't throw rocks at me.

Probably BS, in fact very likely BS. Like I say I haven't even begun to learn php yet. I start in a week or two.

Thanks for the reply though.
Posted:  13 May 2011 23:10
There is already a mechanism in the index.php script, which resets the last used date to the current date (and the event category to 'all categories') if the last visit to the calendar was > 60 minutes ago.
This can be easily set for instance to 15 minutes. (index.php line 40 change 3600 to 900) (3600 and 900 are in seconds)

Is this not sufficient?
Roel
Posted:  14 May 2011 03:41
It probably is sufficient Roel. Nice idea to implement a time out feature. Thanks for the heads up. :)