Product Development and Internet Marketing

I recently launched an events calendar on EverythingNY that formats the Upcoming.org RSS feed into a calendar view. Here's how I did it...

First, I created a database and filled it with RSS entries from Upcoming.org. How do you do that? Read about RSSToMySQL, a package of PHP scripts I developed for downloading RSS feeds into a MySQL database. This is how the "Headlines" feature on ENY works.

Done? OK, now the fun part. Basically, the secret to the calendar view is mingling two MT plugins, the commonly-known MTSQL plugin from Brad Choate, and the less-well-known SomeDays plugin from Chad Everett. SomeDays is a truly sick program. Chad must have a lot of free time on his hands; the README file is like a masters thesis. Anyway, the bottom line is that SomeDays lets you use date contexts without being tied to MT Entries so you can generate a calendar for future or arbitrary dates without using MTCalendar functions.

So now you've got a database full of entries; code for selecting data into MT; and code for formatting data into a calendar. The rest is a matter of formatting. Here's the code I use for the events over the next 30 days.

First, define the date context as the next 30 days after "today":

<table width='584' cellpadding='0' cellspacing='0' align='center'><tr> <MTSomeDays select="+30" date="today" padding="1">

Format the title of each calendar box with either the "eventtitle" or "eventtitletoday" styles to highlight the current day:

<td valign="top" width="14%" class="eventday"> <MTSDIfNotToday><div class='eventtitle'><$MTSDWorkDate format="%a, %b %d"$></div></MTSDIfNotToday> <MTSDIfToday><div class='eventtitletoday'><$MTSDWorkDate format="%a, %b %d"$></div></MTSDIfToday>

Select the data from SQL. This could be different on your system:

<MTSQL query = "select e.entry_id, e.link, e.title, e.description, DATE_FORMAT(e.pub_date, '%l'), DATE_FORMAT(e.pub_date, '%i'), DATE_FORMAT(e.pub_date, '%p') from entry e INNER JOIN feed f ON (e.feed_id = f.feed_id) WHERE to_days(e.pub_date) - to_days(<MTSDWorkDate>)=0 AND f.type = 'E' AND f.blog_id = <MTBlogID> order by DATE_FORMAT(e.pub_date, '%j %H:%i'), e.title;" default="No Events"> <div class='event'> <MTSQLColumn column="5">:<MTSQLColumn column="6"> <MTSQLColumn column="7"> <a href="<MTSQLColumn column="2" decode_xml_smart="1">" target="_new"><MTSQLColumn column="3" decode_xml_smart="1"></a><br /><br /> </MTSQL>

Need to end the row if we're on Saturday:

</TD> <MTSDIfSat></tr><tr></MTSDIfSat> </MTSomeDays> </TR></TABLE>

That's it. Let me know if it works.

November 11, 2003 05:48 PM
Comments