michael.piecko wrote: And this is just the beginning ... Think of support, bugfixing, feature requests, etc. ...![]()
Michael
jillelaine wrote: I have a decent event calender working on my site. I'm using code from activecalendar http://www.micronetwork.de/activecalendar/ It appears to be cleanly written and well-documented.
Activecalendar has example code to read data from a mysql table http://www.micronetwork.de/activecalendar/demo/data/showcode .php?page=mysqlevents.php to display on 'event days'. I created a 'view' table as the data I want to display on 'event days' came from many tables, but I could have just used joins.
I initialized a new module, calendar, and made an indexSuccess.php template. I modified activecalendar's example mysql code to use criteria in my actions.class.php index function, and then added start and end date criteria to reduce the result set. I also optionally 'filter' (with buttons) by group to reduce results further.
I put the file activecalendar.php in my frontend/lib directory (this is the only file I needed from the activecalendar download...I think it could be modified to be a plugin?) and requireonce to load it in my actions.class.php . I modified the CSS to pretty things up.
I'm happy to share more of what I've done if it could be of use. (More code examples here: http://www.micronetwork.de/activecalendar/demo/examples.php )
public function executeCalendar()
{
/*
********************************************************************************
Calendar Navigation variables
********************************************************************************
*/
$this->myurl=$_SERVER['PHP_SELF']."?css=".@$_GET['css']; // the links url is this page
$yearID=false; // GET variable for the year (set in Active Calendar Class), init false to display current year
$monthID=false; // GET variable for the month (set in Active Calendar Class), init false to display current month
$dayID=false; // GET variable for the day (set in Active Calendar Class), init false to display current day
extract($_GET);
/*
********************************************************************************
Create a calendar object
********************************************************************************
*/
$this->cal=new activeCalendar($yearID,$monthID,$dayID);
/*
********************************************************************************
Gets all dates from your database and set the calendar events html classes (for the layout)
********************************************************************************
*/
$c = new Criteria();
$user = $this->getUser()->getGuardUser()->getId();
$subSelect = "sf_guard_event_calendar.ID IN (SELECT sf_guard_event_calendar.ID
FROM sf_guard_user_group, sf_guard_group_event, sf_guard_event_calendar
WHERE sf_guard_user_group.USER_ID = $user
AND sf_guard_user_group.GROUP_ID = sf_guard_group_event.GROUP_ID
AND sf_guard_group_event.EVENT_ID = sf_guard_event_calendar.ID)";
$c1 = $c->getNewCriterion(sfGuardEventCalendarPeer::USER_ID, $user);
$c2 = $c->getNewCriterion(sfGuardEventCalendarPeer::ID, $subSelect, Criteria::CUSTOM);
$c1->addOr($c2);
$c->add($c1);
$c->setDistinct();
$eventList = sfGuardEventCalendarPeer: :doSelect($c);
$eventID="event"; // sets the name of the generated HTML class on the event day (css layout)
foreach($eventList as $event)
{
$mysqlDay=$event->getEventDate('d'); // makes a day out of the database date
$mysqlMonth=$event->getEventDate('m'); // makes a month out of the database date
$mysqlYear=$event->getEventDate('Y'); // makes a year out of the database date
$mysqlContent=$event->getEventTitle(); // gets the event content
$mysqlLink= $this->generateUrl('event', array('id'=>$event->getPrimaryKey())); // gets the event link
$this->cal->setEvent($mysqlYear,$mysqlMonth,$mysqlDay,$eventID); // set the event, if you want the whole day to be an event
$this->cal->setEventContent($mysqlYear,$mysqlMonth,$mysqlDay,$mysqlContent,$mysqlLink); // set the event content and link
}
}<?php
$cal->enableDatePicker(); // this enables the month's datepicker (year range 2002 - 2010)
$cal->enableMonthNav($myurl); // this enables the month's navigation controls
echo $cal->showMonth(); // this displays the month's view
?>Users browsing this forum: No registered users and 0 guests