Webeks.net - freelance programming
freelance programming - php, Joomla, Zend ...
Home :: Articles :: Programming :: Facebook :: Date-picker FBML component

Date-picker FBML component

Written by Miha

I've already wrote about my disappointment that date picker is not a part of FBML. There I also added some JS (FBJS) code that one can use to add a date picker. But this code (especially if you need more than one date to pick) becomes very hard to read and to manage. So I wrote a PHP class that manages and outputs date-picker for us.

PHP date-picker for FBML features

  • improved FBJS code
  • automatic client-side date verification (user cannot input 31. Februar)
  • you can choose between date and date-time picker
  • after submiting get dates in MySQL format like YYYY-MM-DD hh:mm:ss
  • gettext translations

Code structure

_lib/
calendar.js.php
calendar.php
calendar.tmpl.php
img/
cal.gif
sl_SI/
LC_MESSAGES/
main.po

 

Usage

You have to include and create object only once! When object is created you call functions setDateTimeField() and setDateField().

UPDATE: You have to update private $img variable in calendar.php file to direct to existing cal image!!!

Example

require_once('_lib/calendar.php');
$onlyOneObject = new fbCalendarInput();

//date and time input fields
$onlyOneObject->setDateTimeField("firstFieldsNamePrefix");

//we dont care for time, only date input
$onlyOneObject->setDateField("secondOne");

$onlyOneObject->setDateTimeField("third");

Download

Download in compressed ZIP file

Thanks

The JS is based on code provided here.

Thanks to Johnson for giving us a starting point and to all those who have posted their findings and work-arounds to the various FBJS pitfalls. Big thanks to S10sys for producing and sharing their code for a working fbjs date picker.

 

http://test/facebook/fbml-datepicker.html


blog comments powered by Disqus