Page 1 of 1
Calendar Module - Just show today's events? -- A UDT Solution?
Posted: Mon Jun 23, 2008 5:04 pm
by irasanborn
I've searched the forum, but I couldn't find anything about this specific topic, so here is my question:
Is there a way to just show today's events for the Calendar Module? Perhaps a custom template I could add?
CMSMS ver 1.3, Calendar ver 0.8.2
Re: Calendar Module - Just show today's events?
Posted: Tue Jun 24, 2008 6:16 am
by Russ
Hi irasanborn, I felt sure you could do this with Calendar, but looking through the module help and the forum, it would appear not? You could log a request for this as a new feature, or just write yourself a user tag to get the data out of Calendar?
Re: Calendar Module - Just show today's events?
Posted: Tue Jun 24, 2008 1:01 pm
by irasanborn
Ahh well, I was afraid of that. I added it as a feature request. Hopefully the dev's can incorporate that functionality at some point.
In the meantime, since I'm just learning about UDTs, how might you suggest I go about pulling data from the Calendar Module with a UDT?
Thanks in advance.
Re: Calendar Module - Just show today's events? -- A UDT Solution?
Posted: Tue Jun 24, 2008 3:11 pm
by Russ
I'd have a look at one of the list templates for Calendar and see if you can use Smarty to limit the array to todays date?
As for UDT maybe something like below - you'd have to do some other stuff and format the output a bit better (which is why the Smarty template way is by far the best!) Warning this is very rough and ready and not really tested!!
Code: Select all
//CalToday UDT
global $gCms;
$config = $gCms->config;
//Get Timestamps
$sToday = date('Y-m-d',time())." 00:00:00"; //Start of today
$eToday = date('Y-m-d',time())." 23:59:59"; //End of of today
//Get Calendar Event Information from the database
$prefix = $config['db_prefix']; // Database Prefix
$db =&$gCms->db;
//SQL Statement
$Get_Today_Cal = "SELECT event_id, event_title, event_summary, event_details, event_date_start, event_date_end, event_parent_id,event_recur_period, event_date_recur_end, event_created_by, event_create_date, event_modified_date FROM `" . $prefix . "module_calendar_events` WHERE `event_date_start` BETWEEN '$sToday' AND '$eToday';";
$sql = mysql_query($Get_Today_Cal) or die("Unexpected Error: Database or access problem?: ".mysql_error());
//Get data and display
While ($row = mysql_fetch_assoc($sql))
{
//Only some of the event details is shown here
echo "<h3>".$row['event_title']."</h3>";
echo "<p>Summary: ".$row['event_summary']."<br/>";
echo "<p>Details: ".$row['event_details']."<br/>";
echo "<p>Start: ".$row['event_date_start']."<br/>";
echo "<p>End: ".$row['event_date_end']."</p>";
echo "<hr/>";
}
Hope this helps,
Russ
Re: Calendar Module - Just show today's events? -- A UDT Solution?
Posted: Tue Jun 24, 2008 4:50 pm
by irasanborn
Thanks very much, I appreciate your help!
I'll start playing around with this code and post later on how everything works.