Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

dhtml_calendar
Goto page 1, 2, 3, 4, 5  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun Nov 07, 2004 1:54 am    Post subject: dhtml_calendar Reply with quote

I've added a new plugin to the wiki, DHTMLCalendarPlugin that interfaces to the excellent and high quality jscalendar library which is also LGPL'd. You will need jscalendar-1.0.

Usage is similar to that for the overlib library via the {popup*} plugins. Here's the basic idea--

Somewhere in the document head put something like:
Code:
{dhtml_calendar_init src='/path/to/calendar.js' setup_src='/path/to/calendar-setup.js' lang='/path/to/lang/calendar-en.js' css='/path/to/calendar-theme.css'}

Then in your document, you can setup a calendar -- here's a flat calendar:
Code:
<div style="float: right; margin-left: 1em; margin-bottom: 1em;"
id="calendar-container"></div>
{dhtml_calendar flat="calendar-container"}

This time a popup calendar -- note how the plugin comes after the form, though:
Code:

<form ...>
  <input type="text" id="data" name="data" />
  <button id="trigger">...</button>
</form>
{dhtml_calendar inputField="data" button="trigger" singleClick=false}

The extra 'singleClick' parameter is just one of the many options that jscalendar supports and in this case, it means you would have to double-click a date to close the popup. {dhtml_calendar} takes all of the parameters that Calendar.setup() can take (with the same casing as the original parameter names) with the caveat that presently the array based parameters are not properly handled. Refer to the code comments and the jscalendar documentation for more details.


Last edited by boots on Thu May 26, 2005 1:12 am; edited 2 times in total
Back to top
View user's profile Send private message
skot
Smarty n00b


Joined: 23 Jan 2005
Posts: 1

PostPosted: Sun Jan 23, 2005 2:31 am    Post subject: Reply with quote

Hello, I am using Smarty 2.6.6 and I am having some issues getting the calendar to display.

php file:

Code:

<?php

require_once 'TestingApp.php';

$smarty = new TestingApp();

$smarty->display('calendar.tpl');


template:

Code:

<html>

<head>
{dhtml_calendar_init src='js/jscalendar/calendar.js' setup_src='js/jscalendar/calendar-setup.js' lang='js/jscalendar/calendar-en.js' css='js/jscalendar/calendar-blue.css'}
</head>

<body>

<div style="float: right; margin-left: 1em; margin-bottom: 1em;" id="calendar-container"></div>
{dhtml_calendar flat="calendar-container"}

</body>

</html>


html generated:

Code:




<html>

<head>
    <link rel="stylesheet" type="text/css" media="all" href="js/jscalendar/calendar-blue.css">
    <script type="text/javascript" src="js/jscalendar/calendar.js"></script>
    <script type="text/javascript" src="js/jscalendar/calendar-en.js"></script>
    <script type="text/javascript" src="js/jscalendar/calendar-setup.js"></script>

</head>

<body>

<div style="float: right; margin-left: 1em; margin-bottom: 1em;" id="calendar-container"></div>
<script type="text/javascript">Calendar.setup({"flat":"calendar-container"});</script>

</body>

</html>


and I get no calendar, now it looks like everything is being set fine yet I see no calendar. what am I doing wrong here? Thanks.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Jan 24, 2005 6:31 am    Post subject: Reply with quote

Can you reach js/jscalendar/calendar-setup.js (and all the other files listed in the init) directly from your browser's address bar?
Back to top
View user's profile Send private message
gawelczyk
Smarty n00b


Joined: 28 Jan 2005
Posts: 4

PostPosted: Fri Jan 28, 2005 3:33 pm    Post subject: dhmtl_calendar: how to download? Reply with quote

boots wrote:
I've added a new plugin to the wiki, DHTMLCalendarPlugin


good... but how can I download this plugin? There is no link for downloading on the cited web site.

thanks for quick answer

ad
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Jan 29, 2005 1:03 am    Post subject: Reply with quote

Cut and paste the code for each of function.dhtml_calendar_init.php and function.dhtml_calendar.php into their own files (with those names) and put them in your plugin dir. Don't forget to download jscalendar 0.9.6 from http://www.dynarch.com/projects/calendar/ and put it somewhere in your webroot.
Back to top
View user's profile Send private message
gawelczyk
Smarty n00b


Joined: 28 Jan 2005
Posts: 4

PostPosted: Sat Jan 29, 2005 3:20 am    Post subject: download Reply with quote

ok, I thought about it but I am too lasy to do such things Wink and I thought there is a way to download those files.

all the best
ad
Back to top
View user's profile Send private message
sophistry
Smarty Rookie


Joined: 31 Jan 2005
Posts: 33

PostPosted: Tue Feb 08, 2005 9:38 pm    Post subject: doesn't work in safari 1.2.3 Reply with quote

Hi boots!

Checking out one of your other pieces here on Mac OSX Safari 1.2.3

This is what gets put into the date field instead of a date:
Code:

function (par)
{
  return s[par] || par;
}/function (par)
{
  return s[par] || par;
}/function (par)
{
  return s[par] || par;
}


It looks like jscalendar has not been tested in Safari 1.2.3 ; I'm pretty sure that an error like that is not the smarty plugin's problem.

Just a quick update - I've gotten it to work in Firefox 1.0 so I am fairly certain it's jscalendar javascript code breaking down in Safari 1.2.3

Keep up the nice work... I'm learning at a rapid rate from your good examples.
Cheers,
soph
[/code]
Back to top
View user's profile Send private message
sophistry
Smarty Rookie


Joined: 31 Jan 2005
Posts: 33

PostPosted: Tue Feb 08, 2005 10:07 pm    Post subject: safari update Reply with quote

well, it looks like there are some serious workarounds in jscalendar code to deal with konquerer based browsers (Safari is based on konquerer). Mad

But, I am able to use the demo page with Safari 1.2.3 so it does work outside of the plugin. Smile

I get this error in a JS alert dialog box when I click a date on the calendar created by the flat_calendar test code provided in the first post in this thread:

"No flatCallback given -- doing nothing"

additionally, in the status area in the calendar (the one that displays changing messages that tell you what different buttons do) I see that code I posted in the previous post.

Any ideas on where to look? It looks like maybe an eval() is not being properly called. Or maybe some escaping is choking Safari's JS engine.

Thanks for any leads...
soph
Back to top
View user's profile Send private message
sophistry
Smarty Rookie


Joined: 31 Jan 2005
Posts: 33

PostPosted: Tue Feb 08, 2005 11:15 pm    Post subject: maybe server related? Reply with quote

I just stripped jscalendar way down to where I use only the code presented on the dynarch page rather than using the plugin.

And you know what? It still doesn't work!! I still get the function (par) crap being put into the date field.

The demos all work in Safari when they run from the dynarch site but it seems that when I load JS libs from my own server (Apache 2 on Mac OSX.3) something goes freaky - at least that's where I am at right now. I even tried putting the dynarch JS code into my href for the javascript call and that didn't work either.

Any advice?
soph
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Feb 09, 2005 11:30 am    Post subject: Reply with quote

Hi sophistry,

Thanks for checking into this. I don't have access to a mac, so I am in no position to test. I suspect an issue with the jscalendar library since the plugin really does little more than facilitate including the library.

Please post an update if you figure it out and if necessary I will update the plugin.

Greetings.
Back to top
View user's profile Send private message
sophistry
Smarty Rookie


Joined: 31 Jan 2005
Posts: 33

PostPosted: Wed Feb 09, 2005 6:52 pm    Post subject: jscalendar Safari SOLVED Reply with quote

It was a recent bug fix which was committed to CVS but hadn't reached the release copy. See SourceForge bug tracker page for deatils on the code modification needed to get it going:

http://sourceforge.net/tracker/?group_id=75569&atid=544285&func=detail&aid=1008770

phew, I shoulda checked there first - I guess I'm an opensource/CVS tumbling newbie; I'll know next time.

soph
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Feb 09, 2005 6:57 pm    Post subject: Reply with quote

Sophistry--

Ahh, well that explains it. Good sleuthing and thanks for documenting that here as well!
Back to top
View user's profile Send private message
niooi
Smarty n00b


Joined: 24 May 2005
Posts: 4

PostPosted: Tue May 24, 2005 3:30 pm    Post subject: 2 calendars Reply with quote

hello,

Is it possible to have 2 calendars side by side. One for the current month and the other one for the next month (and when the user click on the following month both changes)?

Thanks
Back to top
View user's profile Send private message
sophistry
Smarty Rookie


Joined: 31 Jan 2005
Posts: 33

PostPosted: Tue May 24, 2005 3:38 pm    Post subject: see the jscalendar online docs Reply with quote

the answer is in the documentation for jscalendar. use the source.
Back to top
View user's profile Send private message
Duncan
Smarty Pro


Joined: 16 Dec 2003
Posts: 166

PostPosted: Tue May 24, 2005 9:47 pm    Post subject: Reply with quote

1.0 compatibility

Code:
{dhtml_calendar flat="calendar-container" flatCallback=dateChanged dateStatusFunc=ourDateStatusFunc}

produces
Code:
<script type="text/javascript">Calendar.setup({"flat":"calendar-container","flatCallback":"dateChanged","dateStatusFunc":"ourDateStatusFunc"});</script>

resulting in the calendar not being displayed.
However, removing the "" from the "ourDateStatusFunc" part fixes it, so it seems that the plugin needs to be adjusted for 1.0 compatibility.

As this is the only function I found so far, where this problem occurs, I modified the function.dhtml_calendar.php code as follows:
Edit: flatCallback is affected as well, so also added it to the array.


Added new filter array:
Code:

    $filter_functions = array(
      'flatCallback',
      'dateStatusFunc'
    );


Changed
Code:
else if (!is_numeric($_value))

to
Code:
else if (!is_numeric($_value) && !in_array($field, $filter_functions))


Which fixed it at least for this one problem.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Goto page 1, 2, 3, 4, 5  Next
Page 1 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP