Warwick Blogs Grabber

This is a project I created many years ago, and haven't touched in about 10 to 13 years. It's mainly here for posterity, but if you still find it useful (and if it still works) then by all means feel free to make use of it. Any references to "6 times 9" are because that is the retired website where I was previously hosting things like this.

About

Warwick Blogs Grabber is a PHP script I wrote to grab and process the RSS feed for my Warwick University blog so I could display it on my website at the time, and thanks to the flexibility of Warwick Blogs' RSS feeds the number of entries shown is customisable.

Because the "Title" in all the RSS feeds is always the main title of the blog, the page title can be manually set if the feed is not the main feed (the feed for a tag, for example).

The author of an entry is not output by default, however it is extracted from the feed. If the author is required (for multi-user blogs, for example) then the appropriate code can be easily added or a "custom" display used (see below).

Since RSS is theoretically a standard, WBG should work with non-Warwick-Blogs feeds but may need some tweaking.

Example

There are four display options: normal, list, raw, and custom. "Normal" presents the page as you would expect a blog to appear, and "Custom" reads the RSS feed but doesn't output anything so you can structure it however you like.

"List" and "Raw" are demonstrated below; note that "Raw" is not intended to be a valid PHP array; it is merely a means of presenting the structure of the data, and is useful if you ultimately want to use a custom display.

List display

The default of the 10 most recent posts, presented as a bulleted list.

Powered by Warwick Blogs Grabber

Raw display

The most recent post, presented as the structure of the generated array.

$blogentries=array(
    Not to blow my own party blower... - 1 => array(
        title => Not to blow my own party blower...,
        link => https://blogs.warwick.ac.uk/richardwinskill/entry/not_to_blow/,
        desc => <p>I know I say this every year, but Happy Birthday <em>The randomness of tomorrow, today!</em>!</p>,
        tags => <a href="https://blogs.warwick.ac.uk/richardwinskill/tag/4/" rel="tag" title="Entries tagged with "4"">#4</a> <a href="https://blogs.warwick.ac.uk/richardwinskill/tag/birthday/" rel="tag" title="Entries tagged with "Birthday"">#Birthday</a> <a href="https://blogs.warwick.ac.uk/richardwinskill/tag/blog/" rel="tag" title="Entries tagged with "Blog"">#Blog</a> <a href="https://blogs.warwick.ac.uk/richardwinskill/tag/randomness/" rel="tag" title="Entries tagged with "Randomness"">#Randomness</a>,
        time => 1226340009,
        commenturl => https://blogs.warwick.ac.uk/richardwinskill/entry/not_to_blow/#comments,
        guid => 094d73991623baf101162bd777b7056b,
        commentnum => 2 Comments,
    ),
);
Powered by Warwick Blogs Grabber

Using

Since the processing of the feeds is the same in each case, the 'engine' is a single file that's referenced by each page that needs it. The referencing page is also where the options are set.

Set up

Include the following code wherever you want the blog posts to appear, modifying is as appropriate as explained below. Note that the "Normal" display expects to be its own page, as it outputs the main blog title.

<?php

$wbrssurl='http://blogs.warwick.ac.uk/richardwinskill/tag/video/?rss=rss_2_0';
$wbmainfeed=0;
$zpagetitle='Entries tagged with "Video"';
$displaynum=10;
$firstlink='&lt;&lt; Newest entries'
$prevlink='&lt; Newer entries'
$nextlink='Older entries &gt;'
$blogsort="none"
$blogdisplay="normal"

include 'wbengine.php';

?>

Custom Output

For custom output, with $blogdisplay set to "custom", Warwick Blogs Grabber will compile the $blogentries array but will not output it. This allows you to output the entries however you want. The best way to see the structure of the array is to first use the "raw" display option; this will output the array using HTML formatting (i.e. it will display correctly as a normal webpage). After that you can use your favourite method for looping through an array (such as foreach() in the example above) and then reference each item as you need it.

Most of the data is in its "raw" form; i.e. the link is the URL not an A tag, etc.

However:

Download

To download Warwick Blogs Grabber just right-click and choose "Save As" (or the equivalent for your device/web browser).

Last updated: (version "Foxtrot")