Adventures in PHP: Aggregating Student Blogs Without Wordpress


Image of Page Aggregating Posts

Much of my thinking about student blogs comes from my experience of working with Gardner Campbell in his New Media Faculty Seminar. In that seminar, the crucial component of classroom blogging is the “motherblog”–a central, aggregated space where individual blogs come together. As I ask my students to blog, I know that we need a single point of connection. We’re using Lore for our course management system, but Lore’s interface for sharing materials is lacking; although its “timeline” is something of a datastream, shared content isn’t easy to submit or to work with. I wanted a more usable and accessible solution.

Typically, the “motherblog” problem is solved with Wordpress; however, I wanted a solution that was sleeker, something that lacked the weight of a full-scale CMS. Additionally, I didn’t want to deal with Wordpress’s vulnerabilities, constant updates, or need for an SQL database.

Enter SimplePie, a lightweight, PHP-based RSS feed parser. If you’re comfortable with basic web authoring, it isn’t a difficult solution: upload SimplePie, embed the calls in a PHP document, and watch the posts roll in. I’ve coupled my use of it with Skeleton, a responsive framework, yielding a simple and responsive “motherblog” page without the weight of a full scale CMS behind it.

In this post, I’m going to quickly outline the basic work of assembling such a page. It requires webhosting, a bit of HTML/CSS/PHP knowhow, and some patience. That said, at this point I’ve done very little to modify the basic SimplePie template, and the page is more than serviceable. Once I’ve customized it to my liking, I’ll upload the files to github and update this post. I hope that others can use and expand on this solution.

While this is much more time intensive than simply installing Wordpress and parsing the feeds through a widget, I like to explore new tools each semester. If I ask my students to work with unfamiliar tools, it’s only fair that I do the same. The following documents my process.

Ingredients:

  • A webhost with PHP 5.2 or higher. I’m a longtime user of and big fan of Apis Networks, but any decent webhost will have PHP support.
  • A means of uploading/editing files and changing folder permissions. I use Panic’s Coda, but you could still complete this with free tools like TextEdit and Fetch.
  • The SimplePie installation files. Note: SimplePie has some solid documentation available. Much of what I will document here is available on their site.
  • The Skeleton CSS framework, for your responsive page.

Basic Outline:

  1. On your server, in the root, create a new folder and name it “PHP”. Open the SimplePie installation folder, and, from it, upload SimplePie’s autoloader.php and its library folder.
  2. Determine where you want to host the aggregator and create an index.php file there. My course pages are hosted in individual folders, so my path looks something like COM201/Fall2012/blogs. The path doesn’t matter, but this step does: in the same folder as your index.php file, you need to make a folder named “cache” and set its permissions to writeable – based on your webhost’s settings. In most FTP clients, you can right click on the folder, choose “Get Info” (or something similar) and use a context menu to change this value. You can then edit permissions from a visual interface: A writable value will mostly like be 755, 775, or 777. Depending on your host, this might require a bit of guess and check. If your cache folder isn’t writeable, you’ll get an error when your page is up and running.
  3. Edit your index.php file. I built mine using the first example in the SimplePie documentation. You will need to make a few changes to that page:
    • a. First, change the value of the path to SimplePie. The default is “../autoloader.php” – you will need to update this to reflect your folder structure.
    • b. Second, change the SimplePie feed value from a single page to an array. The template code is:

      $feed->set_feed_url('http://simplepie.org/blog/feed/');

      You will want to change this to:

          
          $feed->set_feed_url(array(
          'http://simplepie.org/blog1/feed',
          'http://simplepie.org/blog2/feed',
          'http://simplepie.org/blog3/feed'
          ));
          
          

      replacing the feeds with the addresses of student blog RSS feeds. Those feeds vary based on service, but in general:
      • Wordpress feeds: ‘http://studentblog.wordpress.com/feed’
      • Blogger feeds: ‘http://studentblog.blogspot.com/feeds/posts/default’
      • Tumblr feeds: ‘http://studentblog.tumblr.com/rss’
      Also remember that each line in the array (except for the final one) should end with a comma, and each blog URL listed in the array should be enclosed in single quotation marks.
  4. Finally, if you want to base your page on the Skeleton framework, you should include its CSS files in the HTML head of your document (as well any web fonts). The head of my document (which I still need to change into HTML5) looks like this: Simple Pie Document Head

If all is well, your page should be aggregating posts. SimplePie’s default cache duration is an hour, so there might be a small delay in the speed at which new posts arrive. Directions for adjusting this value, and for adding any number of variables to your page, are available in the SimplePie API.

At this point, I turned my focus to editing the CSS for the page. Skeleton requires some basic CSS knowledge, but it’s a grid system with predefined classes: Simply add a class value to any element (for example: class=”eleven columns”) to determine its width. I coupled this with textures from SubtlePatterns and some basic CSS shadows to style the page. My page is perfectly functional at this point, but I’d like to do some more styling and come up with a standardized CSS template that I can use across courses. You can take a look at my code by viewing one of the aggregators.

Again, this isn’t the simplest path, but it’s a lightweight solution and endlessly reproducible. I plan to recycle this across future courses, and it doesn’t require numerous Wordpress installations.

If you build on this solution, or have found another way to solve the aggregation problem, I’d love to hear about it.

« The Rhythm of Practice Briefly, on the MLA Job List Discussion »

Comments