Page 1 of 1

how to call the calender script?

Posted: Sat Jan 05, 2008 12:20 pm
by carsten888
when making or editting an item you can set the start-publishing-date using the wonderfull dhtml-calender. I would like to use the calender in my component. so how to call for the javascript-initiation-script?

underneath is the outputted script. So can just paste this in my admin-page, but then the language does not change with the language of the admin-user. So would be neater to get the calender like echo JHTML::_('calender_init_script');

output of the script:

Code: Select all

<script language="javascript" type="text/javascript">
								
				Calendar._DN = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");Calendar._SDN = new Array ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"); Calendar._FD = 0;	Calendar._MN = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");	Calendar._SMN = new Array ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");Calendar._TT = {};Calendar._TT["INFO"] = "About the calendar";
		Calendar._TT["ABOUT"] =
"DHTML Date/Time Selector\n" +
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" +
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
"Distributed under GNU LGPL.  See http://gnu.org/licenses/lgpl.html for details." +
"\n\n" +
"Date selection:\n" +
"- Use the \xab, \xbb buttons to select year\n" +
"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
"- Hold mouse button on any of the above buttons for faster selection.";
Calendar._TT["ABOUT_TIME"] = "\n\n" +
"Time selection:\n" +
"- Click on any of the time parts to increase it\n" +
"- or Shift-click to decrease it\n" +
"- or click and drag for faster selection.";

		Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)";Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)";	Calendar._TT["GO_TODAY"] = "Go Today";Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)";Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)";Calendar._TT["SEL_DATE"] = "Select date";Calendar._TT["DRAG_TO_MOVE"] = "Drag to move";Calendar._TT["PART_TODAY"] = " (today)";Calendar._TT["DAY_FIRST"] = "Display %s first";Calendar._TT["WEEKEND"] = "0,6";Calendar._TT["CLOSE"] = "Close";Calendar._TT["TODAY"] = "Today";Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d"; Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";Calendar._TT["WK"] = "wk";Calendar._TT["TIME"] = "Time:";
window.addEvent('domready', function() {Calendar.setup({
        inputField     :    "created",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "detailscreated_img",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });});
window.addEvent('domready', function() {Calendar.setup({
        inputField     :    "publish_up",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "detailspublish_up_img",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });});
window.addEvent('domready', function() {Calendar.setup({
        inputField     :    "publish_down",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "detailspublish_down_img",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });});

				</script>

Re: how to call the calender script?

Posted: Tue Jan 08, 2008 5:46 am
by jmoises
i am not and expert i been developt my componet and i use this

in my view.html.php

Code: Select all

JHTML::_('behavior.calendar');
in my form.php

Code: Select all

      <tr>
        <td width="100" align="right" class="key"><label for="fecha_nacimiento"> <?php echo JText::_( 'Fecha de Nacimiento' ); ?>: </label>
        </td>
        <td><input class="text_area" type="text" name="fecha_nacimiento" id="fecha_nacimiento" size="25" maxlength="19" value="<?php echo $this->talentos->fecha_nacimiento;?>" /> <input type="reset" class="button" value="..." onclick="return showCalendar('fecha_nacimiento','%Y-%m-%d');" />
		</td>
      </tr>
i hope this help.

Re: how to call the calender script?

Posted: Tue Jan 08, 2008 7:48 am
by carsten888
thank you.

Code: Select all

JHTML::_('behavior.calendar');
this code does not give me any output.

did I forget something?

Re: how to call the calender script?

Posted: Tue Jan 08, 2008 5:00 pm
by jmoises
that work for me using Joomla 1.5 not sure work on Joomla 1.0

Re: how to call the calender script?

Posted: Tue Jan 08, 2008 5:30 pm
by jmoises
or try some like this

Code: Select all

<?php echo JHTML::_('calendar', $this->talentos->fecha_nacimiento, 'fecha_nacimiento', 'fecha_nacimiento'); ?>

Re: how to call the calender script?

Posted: Sun Jan 13, 2008 8:25 am
by carsten888
Code:

JHTML::_('behavior.calendar');

this code does not give me any output.

did I forget something?
that was on 1.5. but nothing.

Joomla 1.0.x does not use calender-init-javascript like joomla 1.5. So what I'm looking for only has to work in 1.5.

Re: how to call the calender script?

Posted: Sun Jan 13, 2008 8:37 am
by carsten888
:-[
ahem...

I forgot to put echo in front.

this works:
echo JHTML::_('behavior.calendar');

thank you very much jmoises!

Re: how to call the calender script?

Posted: Mon Jan 14, 2008 10:47 pm
by jmoises
Sure no problem carsten888 !

Re: how to call the calender script?

Posted: Tue Jan 15, 2008 3:29 pm
by carsten888
ahum. just another think.
It does not echo the init-script.

echo JHTML::_('behavior.calendar'); outputs:

Code: Select all

Calendar._DN = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");Calendar._SDN = new Array ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"); Calendar._FD = 0;	Calendar._MN = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");	Calendar._SMN = new Array ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");Calendar._TT = {};Calendar._TT["INFO"] = "About the calendar";
		Calendar._TT["ABOUT"] =
"DHTML Date/Time Selector\n" +
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" +
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
"Distributed under GNU LGPL.  See http://gnu.org/licenses/lgpl.html for details." +
"\n\n" +
"Date selection:\n" +
"- Use the \xab, \xbb buttons to select year\n" +
"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
"- Hold mouse button on any of the above buttons for faster selection.";
Calendar._TT["ABOUT_TIME"] = "\n\n" +
"Time selection:\n" +
"- Click on any of the time parts to increase it\n" +
"- or Shift-click to decrease it\n" +
"- or click and drag for faster selection.";

		Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)";Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)";	Calendar._TT["GO_TODAY"] = "Go Today";Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)";Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)";Calendar._TT["SEL_DATE"] = "Select date";Calendar._TT["DRAG_TO_MOVE"] = "Drag to move";Calendar._TT["PART_TODAY"] = " (today)";Calendar._TT["DAY_FIRST"] = "Display %s first";Calendar._TT["WEEKEND"] = "0,6";Calendar._TT["CLOSE"] = "Close";Calendar._TT["TODAY"] = "Today";Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d"; Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";Calendar._TT["WK"] = "wk";Calendar._TT["TIME"] = "Time:";
so missing is:

Code: Select all

window.addEvent('domready', function() {Calendar.setup({
        inputField     :    "detailscreated",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "detailscreated_img",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });});
window.addEvent('domready', function() {Calendar.setup({
        inputField     :    "detailspublish_up",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "detailspublish_up_img",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });});
window.addEvent('domready', function() {Calendar.setup({
        inputField     :    "detailspublish_down",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "detailspublish_down_img",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });});
function keepAlive( ) {	var myAjax = new Ajax( "index.php", { method: "get" } ).request();} window.addEvent("domready", function(){ keepAlive.periodical(3540000 ); });

Re: how to call the calender script?

Posted: Mon Nov 17, 2008 5:56 am
by ongray217
<?php echo JHTML::_('calendar', $this->talentos->fecha_nacimiento, 'fecha_nacimiento', 'fecha_nacimiento'); ?>

this is working fine for me in 1.5, but i am not sure why sometime the calendar does not pop-up beside the input field. How to get the calendar align?

Re: how to call the calender script?

Posted: Thu Dec 04, 2008 11:24 pm
by h2mao
The new code in Joomla 1.5 is quite simple.

This line will include JS and CSS

Code: Select all

JHTML::_('behavior.calendar');
Then in your output file(tmpl\default.php or templates...):

Code: Select all

<?php echo JHTML::_('calendar', $search_moviedate, 'search_moviedate', 'search_moviedate'); ?>
The same question is could I define the popup calender picker just "beside" or "under" the img-button?

Re: how to call the calender script?

Posted: Tue Mar 03, 2009 1:55 pm
by dduygushh
Hello,
I also tried to use calender. in v1.5.x it dosen't give me any popup, it dosen't work properly. also in my component where do I have to add

Code: Select all

JHTML::_('behavior.calendar');
I have 3 view.html.php files. I add the code to everyone of them. But I don't if it doesn't work because of this. I'm confused...Can anyone help me? May be I can sen my component to solve the problem :( don't know...

Re: how to call the calender script?

Posted: Tue Mar 03, 2009 2:02 pm
by dduygushh
Ok problem solved. Calender works properly. But I also have another problem about date form. I want to use as %d%m%Y, but mySql uses %Y%m%d. Also after adding new or registered data by using my component from the admin panel; it dosen't show anything but the publishing info. Can anyone help me for these problems?

Re: how to call the calender script?

Posted: Wed Mar 04, 2009 12:37 am
by ongray217
I also have the alignment problem, anyone have solution to this issue?

dduy,
you can do the trick at SQL query level. using STR_TO_DATE (str, format) : convert a string to datetime; return datetime

To set date value of ‘2007-02-01’ into your table from any format
INSERT INTO yourtable (datefield) VALUES ( str_to_date('$inputdate', '%d/%m/%Y') );
OR
UPDATE mytable SET mydate=str_to_date('01/02/2007', '%d/%m/%Y') WHERE id=22;

Re: how to call the calender script?

Posted: Wed Mar 04, 2009 7:56 am
by torkil
Use JDate to convert dates:

Small example:

$date = JFactory::getDate($yourDate);
echo $date->toFormat('%Y-%m-%d %H:%M:%S');

You can also use the date format from your language settings:

echo $date->toFormat(JText::_('DATE_FORMAT_LC2'));


These formats can be found in the en-EN.ini-file in the language folder. Replace en-EN with your language of course.

Re: how to call the calender script?

Posted: Wed Mar 04, 2009 1:13 pm
by ongray217
anyone have problem with the alignment? or it's only me :(
it does not happen all the time, it only happen if i have a big form.

Re: how to call the calender script?

Posted: Tue Oct 06, 2009 2:31 pm
by KarenGW
I had a problem with alignment too, but I just used smaller forms and it is fine now.

Re: how to call the calender script?

Posted: Mon Jun 14, 2010 11:12 am
by carsten888

Code: Select all

JHTML::_('behavior.calendar');
echo JHTML::calendar('14-06-2010','field_name', 'field_id',"%d-%m-%Y");

Re: how to call the calender script?

Posted: Wed Dec 05, 2012 12:37 pm
by kishoremnk
Hello to all,

This is my calendar script : (I am using this in J2.5)

<?php echo JHTML::_('calendar', '', 'enddate', 'enddate', '%Y-%m-%d', array('class' => ' validate clear'), 'onchange = checkdate()');?>

I need to show the calendar pop-up onclick on the input text box, but the calendar opens when you click on the calendar image. How to get this calendar pop-up when ever you click on text box of that calendar.

Thanks in advance.