Linked @ del.icio.us

rss icon Mark J. Reeves November, 2007

August 16, 2007 EE: Aggregating content using Magpie and ExpressionEngine

This is the first of what will hopefully be a continuing series of posts on using ExpressionEngine to power your blog or web site. ExpressionEngine is a feature-rich content management system used by web designers and developers to power their own and their clients’ web sites. ExpressionEngine works for me as a flexible rendering engine that accommodates custom fields, easy content entry, and a tag-based templating system that anyone can use to store HTML or pre- and post-processed PHP. With ExpressionEngine, I know I’ll never have to say, “sorry, the CMS won’t do that.”

I recently rearranged and redesigned things here on C77 Studios and one of my goals was to pull in external content server-side. I’d been using JSON code to pull in my del.icio.us links, which was frustrating me as the JavaScript call to the remote URL would sometimes stall the loading of the full page.

Magpie is a PHP RSS parser and caching mechanism that pulls RSS feeds from a remote URL and provides an API to grab content and include it in your page output. What’s even better is the Magpie ExpressionEngine plugin that was available by default in my install.

The plugin does the same thing that the PHP Magpie parser does: it provides an API to grab and parse RSS feeds as well as cache them on the server using a timeout parameter. The caching mechanism is useful. Not only does it queue content for fast page rendering if the remote URL happens to be offline, it also prevents bombarding the URL and getting denied. I saw this happen when I reduced the timeout value and found my del.icio.us feed unavailable for a while.

The tag-based syntax for the Magpie ExpressionEngine plugin is really simple:

{exp:magpie url="http://feeds.feedburner.com/ModernHomesNewEngland" limit="4" refresh="60"}
{items}<p><a href="{magpie:link}">{title}</a></p>{/items}{/exp:magpie}

Really simple: Open and close the exp:magpie tag with a feed URL, limit (number of items to show), and a refresh value for the cache (in minutes). For the items pulled, grab bits from each, in this case the title and link for each post.

The example here, that appears in the footer of the page, is from ModernHomesNewEngland, another blog I maintain, so this lets me pull all my blogs together in one portal. I’ve also, as I mentioned, pulled in the latest 12 items from my del.icio.us bookmarks (on the right side of the page), allowing my del.icio.us account to server double-duty: the portable bookmarking tool it’s intended to be, and a tool for me to post quick links to my blog. Finally, I’m using the Magpie plugin to pull my latest Twitter post in as a caption in the photo, capturing a quick thought that I can post anytime, anywhere using my cell phone.

If you maintain a personal blog or homepage, and contribute to other blogs, or wish to pull your del.icio.us posts in as content for your blog, Magpie on PHP is a powerful tool to grab them server-side rather than having a user’s browser do all that work in JavaScript. From a content perspective, this is the ultimate goal: Turn your homepage into a publication with lots of good content and resources. Web 2.0 and the API Web have us posting bits and bites (and bytes) all over the place, and it’s all good content. Magpie helps us easily aggregate all that in one central spot and ExpressionEngine’s tag-based plugin makes it even easier.

For more posts about ExpressionEngine, visit http://www.c77studios.com/archives/category/expressionengine.

Read more in the Archives

Mark J. Reeves has been making web sites work since 1998. Currently partnering with designers and firms throughout the Northeast, he pursues front-end development par excellence coupled with experienced database design and development and solid PHP/MySQL or .NET/SQL Server application development. Design-savvy but not a designer, Mark approaches each project enthusiastic about the details and the potential for online success, offering strategic insight on content and marketing decisions.

Mark resides in Salem, Massachusetts with his wife and infant son in a condo that was once a classroom in an 1870s school. With a growing interest in modern architecture, sustainable living and plans to build his own home someday, Mark's also working on a regional community site at ModernHomesNewEngland.com. Get in touch: mjr@c77studios.com.