NAME: Datepick, a Smarty plugin application VERSION: 1.0.2 AUTHORS: Monte Ohrt CREDITS: Adi Sieker (help with javascript) DEMO: http://www.phpinsider.com/datepick_test/ SYNOPSIS:
{datepick form="myForm" field="mydate"} {datepick form="myForm" field="startDate" theme="cool"} {html_select_date} {datepick form="myForm"} {html_select_date prefix="myDate"} {datepick form="myForm" field="myDate_Year,myDate_Month,myDate_Day"}
DESCRIPTION: Datepick is a php application that puts a calendar icon next to date entries in a form. A user can click on the icon and pick a date visually from a calendar. This date is then automatically populated into the form. Although Datepick is meant to be a plugin to the Smarty template language, it can easily by used with any HTML form, whether it is a static HTML file or dynamically generated from PHP (or any other language.) REQUIREMENTS: Datepick requires PHP 4.1.0 or later (unless you replace $_GET with $HTTP_GET_VARS and be sure it is global scope, I have not tested this.) Datepick requires the Smarty template language. Be sure Smarty.class.php is in your php_include path. Datepick uses Smarty templates to generate the calendar, so you can easily customize this by editing the template. Datepick requires the PEAR libraries that come with PHP. In particular, you will need the Calc.php class within the Date directory. Be sure the PEAR library directory is in your php_include path. INSTALLATION: In the distribution, you will find the following: /smarty_datepick/ --> the directory of required files /datepick_test/ --> a working example of datepick /plugins/function.datepick.php --> Smarty plugin function README --> this file Put the /smarty_datepick/ directory under your document root. If you wish to place this in a different location, you will need to edit the template files (templates/index.tpl) and adjust the paths accordingly. Change the permissions of the templates_c directory such that the web server user can write to them. Put the plugins/function.datepick.php file into your Smarty plugins directory. Datepick is now ready for use. To test the installation, place the /datepick_test/ directory under the document root, change the permissions of its templates_c directory and go to /datepick_test/ in your browser. You should see something similar to the demo from the phpinsider.com website. USAGE AS SMARTY PLUGIN: In your smarty template, you must supply the javascript somewhere on the page. Put this anywhere (at the bottom, just above works well): Now lets create a form and use Datepick a few different ways:
{datepick form="myForm" field="mydate"} {html_select_date} {datepick form="myForm"} {html_select_date prefix="myDate"} {datepick form="myForm" field="myDate_Year,myDate_Month,myDate_Day"}
With method 1, Datepick will be populating a text field in the form. Simply supply the name of the form and the name of the text field when calling datepick. With method 2, Datepick will populate three dropdown menu items generated by the {html_select_date} function. If you do not suppy a field parameter, Datepick assumes that you will use the default field names generated by {html_select_date}. If you alter the default field names of {html_select_date} with a prefix parameter, you must supply all three field names comma separated, like the example above. ({html_select_date} field names always end with _Year, _Month and _Day.) USAGE AS STANDALONE APPLICATION: If you want to use Datepick outside of Smarty templates, you can do so. But, the Datepick application itself still requires the presence of Smarty since it generates the calendar with Smarty templates. In your HTML form, you would use Datepick like so:
THEMES: You can create different themes for datepick, just do the following: In the smarty_datepick/templates folder, you will find a default/ folder. Copy this directory and its contents to another folder name (new theme). Do the same for the folder in the smarty_datepick/images directory. Let say you want to make a new theme called "blue" cd smarty_datepick/templates cp -r default blue cd ../images cp -r default blue Now edit the template(s) in the templates/blue directory, and edit the image(s) in the images/blue directory. To use this new theme, call the plugin with the appropriate theme name. {datepick form="myForm" theme="blue"} Or if you're using datepick manually: COPYRIGHT: Copyright (c) 2001,2002 ispi of Lincoln, Inc. All rights reserved. This software is released under the GNU Lesser General Public License.