Tag Archives: Web

RSS aggregation for PHP

I have written a mechanism in PHP that can take several RSS feeds, filter and manipulate them, and re-display them in either RSS or straight HTML.

This can also manipulate content (through the preg_replace function, and configurable per-feed), such as removing names from Twitter entries. I’m using it on to show all relevant items from both this blog and my Twitter feed automatically, as an alternative to creating a separate blog. I’m also using it on this blog, to incorporate blog entries and Twitter postings.

It uses the MagpieRSS RSS parser for PHP, which provides some nice functionality, including caching.

Here’s the code:

To use it, unzip it to somewhere in your webroot, then edit aggregate.php and possibly rss.php to set your configuration. Make sure that either the aggregate directory is writable, or create a ‘cache’ directory within and make that writeable, to enable caching. Point your web browser to the rss.php file to immediately view an RSS feed aggregating your supplied feeds. To add a link to the RSS from a website, add it in the header:

<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="" />

To include content in a website, the provided render_aggregate_items function will do most of the work, or you can write your own rendering code. You just have to include the file, use the functions to obtain and draw the content, and then provide your own CSS styling. Example:

<div class="items">

A more comprehensive example is in sample.php.

The code is GPL, so use it however you want – keep the header comments there, though.

Also tagged , | Comments closed

Custom Permalinks


Custom Permalinks is a WordPress plugin that gives you ultimate control over your site structure.

Lay out your site the way you want it. Set the URL of any post, tag or category to anything you want. Old permalinks will redirect properly to the new address.

Read More »

Also tagged , | Comments closed

Some useful mini-plugins for WordPress

Originally for my own use, I put together a couple of WordPress plugins, which I thought I’d make available in case they were useful to anyone else.

Google AdSense shortcode

This is the simplest plugin, which provides an ‘adsense’ shortcode to output a Google ad. To use it, use Google’s tools to create the ad, then paste it into the php file where indicated, then put {adsense} (replace the curly braces with square brackets) in posts/pages where you want the ad to appear (remove the spaces around the square brackets).

And now for a demo + shameless attempt at monetization:

Media player

This one is useful if you occasionally post a video file on your blog, and host it locally. If you use video more frequently, there are plugins that probably are more suited, but I personally didn’t want the overhead, and I wanted to store videos in the standard upload locations, instead of having a separate repository, which seems to be what other plugins do.

This one uses the JW FLV player, provided in the plugin. Use something like:

{media source="" width="400" height="308" preview=""}

(replace the curly braces with square brackets)

I used this just the other day on a post demonstrating the output of the simulator I’ve written for my PhD.

Music player

This is the plugin that renders the content for my music page, as well as providing mini-players for other posts. Give it a path to a directory, and it will display all mp3 files in that directory with flash players based on the XSPF Web Music Player. Recently-added mp3 files will be marked as ‘New’. Use something like:

{musiclist path="path/to/my/music"}

(replace the curly braces with square brackets; add optional nolink=”true” parameter to avoid linking to the mp3 files from their titles)

For just one track, use:

{audio source="path/to/audio.mp3"}

Also tagged , | Comments closed

Saying no to IE 6

Edit: Whoa! now links to Microsoft, and the script is gone!  What gives?  Buyout? Hostile takeover?


IE 6 visitors to this site will notice a message sliding down from the top of the page directing them to update IE. This is a script provided by who are all about making IE6 go away. Bravo I say. That said, I’d be happy if it directed users away from IE altogether (because it sucks; even the U.S. government is ‘pleading users to stop‘ using it) but – one step at a time.

Visit their site to grab the markup for the script if you’re interested in supporting the cause from your site too. Save a developer today!

Tagged | Comments closed

Twitter posting lists with images


Recently I released some code to discover and embed Twinkle images linked from Twitter postings, and released a modification to Ricardo González’s Twitter for WordPress plugin which uses it.

I’ve now implemented support for Twitpic as well.

Grab the modified WordPress plugin here:

After installation, add the widget and make sure ‘Discover images’ is ticked.

For non-Wordpress users, the base code is also available here:

Include it in your twitter list source code, and use it as a filter for the message content. Something like:

$message = TwitterImageUtil::processContent($message, $mysql_database_handle);

Some configuration is possible – see the header comments for more details.

The code will create a thumbnail of the image, and store it locally. It’ll also cache the results in a MySQL database for speed. It supports Lightbox, too – just supply the relevant flag to turn it on.


  • Version 0.2.6: Bugfix for posts with both images and @mentions
  • Version 0.2.5: Bugfix from prior version, plus compatibility fix for Twitpic changes
  • Version 0.2.4: Updated to match Twitter for WordPress v1.9.2: Compatibility fix for WP 2.7
  • Version 0.2.3: Another update, chasing the moving target that is Twitpic
  • Version 0.2.2: Updated to match Twitpic’s new image storage using Amazon S3.
Also tagged , , , | Comments closed

Advanced web templating with PHP and regular expressions

This post describes a method to gain more control over the styling of images for web templates/blog themes, using a bit of Regular Expression magic. This is the technique used for my recent theme, Elegant Grunge.

You’ve just designed the most beautiful template ever – pleasing composition, clean lines, smooth colours and gradients and an awesome typeface. You apply it as the theme for your blog, or release it to the community, and there is much rejoicing.Example of the 'SH Trocadero' WordPress theme with image

Then you or someone else inconsiderately puts a photograph into a post – disaster! That nasty square of graphic just destroyed your composition, and the page is unbalanced and suddenly looks terrible.

Images are particularly tricky to make work with a theme, mostly because they’re so unpredictable. With text, it’s easy to control the way it looks. With images, they can be any colour or shape, many of which will break the composition of a theme, especially if the design elements of the theme contains irregular lines.

A big impediment to making images work is the limitations introduced by the current versions of CSS: All you can really do is provide a square border, possibly with some padding. That’s it, unless you’re willing to manually add tons of markup around images every time – and willing to make your users do it, if you’ve released a theme.Example of images in the "Green Light" WordPress theme

Some people will carefully Photoshop-up their images to make them fit – Webdemar (who made the theme I first used on my blog) does this, for example, and it looks great. That’s a lot of work, though, especially if you make frequent posts with images!

If you’re a theme designer, there’s an easier way to make images work.

Read More »

Also tagged , , , , | Comments closed

“Elegant Grunge” WordPress theme

“Elegant Grunge” is an unwashed yet crisp WordPress theme inspired by It features:

  • Layouts options
  • Support for custom background and header
  • Widget-ready footer
  • Optional full-width page template that removes the sidebar


Read More »

Also tagged , , | Comments closed

New WordPress theme

I’ve designed a new WordPress theme that uses grungey elements I found in some old photos around Carlton, inspired by Function’s theme. It has some cool features –

  • Images are automatically surrounded by frame eyecandy, with some nifty regex replacement – it really makes images pop
  • A photoblog tag page displays entries in a photoblog style
  • A custom page template allows sidebar customisation – supply a list of tags to display related posts, and display arbitrary text/html.
  • Per-page and per-post configuration, and global configuration via admin interface

Let me know what you think – and if it’s broken for you. I’ll release it publicly soon if all is well.

screenshot.png 200810051416.jpg

Also tagged | Comments closed