29 April 2010 9 Comments

Customizing Joomla Calendar Setup

Joomla 1.5 has calendar-setup.js file to setup the joomla calendar as per your requirements.
You can customize jcalendar using a javascript callback functions “param_default”.
Here are some examples customizing your joomla calendar.

Disable all past dates.
Your function where your call the calendar.

function disableDate(d)
{
today = new Date();
difference = d – today;
days = Math.round(difference/(1000*60*60*24));
if( days > -1 )return false;
return true;
}
Now replace the following code from calendar-setup.js
param_default(disableFunc“, null) ;
to

param_default(“disableFunc“, disableDate) ;

Enable Only Specific Day
function
disableDate(d)
{
// Enable only Monday of all months
if( d.getDay()==1 ) return false ;
return true ;
}
Since the changes in
param_default(“disableFunc”, null);
in calendar-setup.js will reflect to all the date fields  in your site pages, in order to reflect the customization in specific date field modify above callback function to

if(params.inputField==”custom_date”)
{
param_default(“disableFunc“,disableDate);
}
else
{
param_default(“disableFunc“,null);
}
custom_date is my date text filed name

VN:F [1.8.8_1072]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.8_1072]
Rating: 0 (from 0 votes)

9 Responses to “Customizing Joomla Calendar Setup”

  1. Ganesh 10 June 2010 at 7:17 am #

    Hi, i am a newbie to joomla.
    I cant find the calendar calling function.
    could you please tell me where is should search for calendar calling function :)

    UN:F [1.8.8_1072]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.8_1072]
    Rating: 0 (from 0 votes)
  2. admin 10 June 2010 at 7:48 am #

    Joomla has HTML Utility class for all HTML drawing classes.
    To Displays a calendar control field use this class with calendar method.

    void calendar (string $value, string $name, string $id, [string $format = '%Y-%m-%d'], [array $attribs = null])

    Example:
    JHTML::_(‘calendar’,”, ‘custom_date’, ‘custom_date’, ‘%Y-%m-%d’, array(‘class’=>’inputbox’, ’size’=>’8′, ‘maxlength’=>’19′));

    UA:F [1.8.8_1072]
    Rating: 0.0/5 (0 votes cast)
    UA:F [1.8.8_1072]
    Rating: 0 (from 0 votes)
  3. Ganesh 10 June 2010 at 8:01 am #

    sorry for messing up with my question..

    actually i dont know the exact location where to put the following thing

    function disableDate(d)
    {
    today = new Date();
    difference = d – today;
    days = Math.round(difference/(1000*60*60*24));
    if( days > -1 )return false;
    return true;
    }

    UN:F [1.8.8_1072]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.8_1072]
    Rating: 0 (from 0 votes)
  4. admin 10 June 2010 at 8:06 am #

    Place this JavaScript code in the same view page where your are calling the calendar control.
    If your view is default.php , just place this code in default.php.
    I hope your will get it. :D

    UA:F [1.8.8_1072]
    Rating: 0.0/5 (0 votes cast)
    UA:F [1.8.8_1072]
    Rating: 0 (from 0 votes)
  5. Ganesh 10 June 2010 at 9:20 am #

    when i change the calendar-setup.js from

    param_default(“disableFunc“, null) ;
    to
    param_default(“disableFunc“, disableDate) ;

    My calendar is not showing up…

    UN:F [1.8.8_1072]
    Rating: 5.0/5 (1 vote cast)
    UN:F [1.8.8_1072]
    Rating: 0 (from 0 votes)
  6. admin 10 June 2010 at 12:24 pm #

    media/system/js/calendar-setup.js

    UA:F [1.8.8_1072]
    Rating: 0.0/5 (0 votes cast)
    UA:F [1.8.8_1072]
    Rating: 0 (from 0 votes)
  7. Ganesh 10 June 2010 at 12:53 pm #

    ya, i changed it at the place you mentioned.

    still no success.

    UN:F [1.8.8_1072]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.8_1072]
    Rating: 0 (from 0 votes)
  8. admin 11 June 2010 at 7:06 am #

    <script>
    function disableDate(d)
    {
    today = new Date();
    difference = d – today;
    days = Math.round(difference/(1000*60*60*24));
    if( days > -1 )return false;
    return true;
    }
    </script>

    UA:F [1.8.8_1072]
    Rating: 0.0/5 (0 votes cast)
    UA:F [1.8.8_1072]
    Rating: 0 (from 0 votes)
  9. jasper 18 June 2010 at 3:11 pm #

    got the same problem as ganesh no showing calendar!!

    UN:F [1.8.8_1072]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.8_1072]
    Rating: 0 (from 0 votes)

Leave a Reply