how to call the calender script?

Joomla! Documentation Workgroup

Moderator: Documentation

Locked
User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1224
Joined: Sat Feb 11, 2006 8:32 am
Contact:

how to call the calender script?

Post by carsten888 » Sat Jan 05, 2008 12:20 pm

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>
Last edited by carsten888 on Tue Jan 15, 2008 3:27 pm, edited 1 time in total.
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
jmoises
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 132
Joined: Tue Mar 28, 2006 3:05 am
Location: Tijuana
Contact:

Re: how to call the calender script?

Post by jmoises » Tue Jan 08, 2008 5:46 am

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.
Jorge Moises
Grupo123.Net - Creando Ideas
http://www.123Hospedaje.com

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1224
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: how to call the calender script?

Post by carsten888 » Tue Jan 08, 2008 7:48 am

thank you.

Code: Select all

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

did I forget something?
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
jmoises
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 132
Joined: Tue Mar 28, 2006 3:05 am
Location: Tijuana
Contact:

Re: how to call the calender script?

Post by jmoises » Tue Jan 08, 2008 5:00 pm

that work for me using Joomla 1.5 not sure work on Joomla 1.0
Jorge Moises
Grupo123.Net - Creando Ideas
http://www.123Hospedaje.com

User avatar
jmoises
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 132
Joined: Tue Mar 28, 2006 3:05 am
Location: Tijuana
Contact:

Re: how to call the calender script?

Post by jmoises » Tue Jan 08, 2008 5:30 pm

or try some like this

Code: Select all

<?php echo JHTML::_('calendar', $this->talentos->fecha_nacimiento, 'fecha_nacimiento', 'fecha_nacimiento'); ?>
Jorge Moises
Grupo123.Net - Creando Ideas
http://www.123Hospedaje.com

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1224
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: how to call the calender script?

Post by carsten888 » Sun Jan 13, 2008 8:25 am

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.
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1224
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: how to call the calender script?

Post by carsten888 » Sun Jan 13, 2008 8:37 am

:-[
ahem...

I forgot to put echo in front.

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

thank you very much jmoises!
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
jmoises
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 132
Joined: Tue Mar 28, 2006 3:05 am
Location: Tijuana
Contact:

Re: how to call the calender script?

Post by jmoises » Mon Jan 14, 2008 10:47 pm

Sure no problem carsten888 !
Jorge Moises
Grupo123.Net - Creando Ideas
http://www.123Hospedaje.com

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1224
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: how to call the calender script?

Post by carsten888 » Tue Jan 15, 2008 3:29 pm

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 ); });
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
ongray217
Joomla! Intern
Joomla! Intern
Posts: 67
Joined: Sat Jun 14, 2008 4:07 pm
Location: Kuala Lumpur, Malaysia
Contact:

Re: how to call the calender script?

Post by ongray217 » Mon Nov 17, 2008 5:56 am

<?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?
Raymond Ong (ongray[at]evolucent[dot]net)
Website: http://www.evolucent.net

User avatar
h2mao
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Oct 09, 2008 11:58 pm

Re: how to call the calender script?

Post by h2mao » Thu Dec 04, 2008 11:24 pm

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?

dduygushh
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Tue Mar 03, 2009 1:39 pm

Re: how to call the calender script?

Post by dduygushh » Tue Mar 03, 2009 1:55 pm

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...

dduygushh
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Tue Mar 03, 2009 1:39 pm

Re: how to call the calender script?

Post by dduygushh » Tue Mar 03, 2009 2:02 pm

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?

User avatar
ongray217
Joomla! Intern
Joomla! Intern
Posts: 67
Joined: Sat Jun 14, 2008 4:07 pm
Location: Kuala Lumpur, Malaysia
Contact:

Re: how to call the calender script?

Post by ongray217 » Wed Mar 04, 2009 12:37 am

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;
Raymond Ong (ongray[at]evolucent[dot]net)
Website: http://www.evolucent.net

User avatar
torkil
Joomla! Guru
Joomla! Guru
Posts: 726
Joined: Wed Aug 24, 2005 9:34 am
Location: Rørvik, Norway
Contact:

Re: how to call the calender script?

Post by torkil » Wed Mar 04, 2009 7:56 am

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.

User avatar
ongray217
Joomla! Intern
Joomla! Intern
Posts: 67
Joined: Sat Jun 14, 2008 4:07 pm
Location: Kuala Lumpur, Malaysia
Contact:

Re: how to call the calender script?

Post by ongray217 » Wed Mar 04, 2009 1:13 pm

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.
Raymond Ong (ongray[at]evolucent[dot]net)
Website: http://www.evolucent.net

KarenGW
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Oct 06, 2009 2:26 pm

Re: how to call the calender script?

Post by KarenGW » Tue Oct 06, 2009 2:31 pm

I had a problem with alignment too, but I just used smaller forms and it is fine now.
Ok, Ok, one at a time! I get tired of all you people nagging at me!
My birthday is in November so you better put it on your calendar.

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1224
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: how to call the calender script?

Post by carsten888 » Mon Jun 14, 2010 11:12 am

Code: Select all

JHTML::_('behavior.calendar');
echo JHTML::calendar('14-06-2010','field_name', 'field_id',"%d-%m-%Y");
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
kishoremnk
Joomla! Intern
Joomla! Intern
Posts: 75
Joined: Fri Sep 18, 2009 5:24 am
Contact:

Re: how to call the calender script?

Post by kishoremnk » Wed Dec 05, 2012 12:37 pm

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.
Nanda Kishore (PHP Developer - welcome to any suggestions / help / guiding regarding PHP and Joomla)
http://www.avidit.in/


Locked

Return to “docs.joomla.org - Feedback/Information”