The one item on my to-do list which has been there the longest has been to add a CMS to control the news section on our website. Typical for a web-development company, our own website is the last thing on our priority. Well, today I can knock it off my list, all thanks to WordPress. After toying with a couple of proprietary products, or the possibility of writing something myself (yeah, sure, I’ve got the time for that) I realised that all I really wanted was a cut-down blog. There’s no need for comments or any of the other features, but the interface, along with the ability to restrict authors to certain activities fit the bill exactly. Not to mention the ability to have RSS/Atom feeds.

Because I had limited time, the solution I came up with is a bit of a messy hack, but it works. I have a fairly simple principle with development: If it works, it was the right way to do it.

All I did was install WordPress into the /news directory and change the index.php to wp_index.php and completely strip the index.php file from the template down to display the minimum amount of details possible:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<br />
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

Now, the ‘right’ way to do this would have been to take the template from our site and turn it into a theme in WordPress, and I do actually plan to do this in the future. But the solution I’ve got here is much simpler, if a bit dirty. On the news index page, I’ve used the PHP fopen() function to pull the contents of wp_index.php and display it in the page. See this code:

<?php
$handle = fopen("http://www.liquoriceap.net/news/wp_index.php?".$_SERVER['QUERY_STRING'], "r");
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
echo $buffer;
}
fclose($handle);

if ($_SERVER['QUERY_STRING']) {
print "<br /><a href=\"/news/\">Back</a>";
}
?>

The advantage here is that if the user clicks on the (more...) link the page will display the story on its own, allowing us to have permalinks for the stories.

WordPress has fit the bill exactly. The interface is clean and simple enough that even non-tech people here can update the news, the file upload interface removes the need to use an FTP program to upload the images, and if necessary I can install a WYSIWYG editor plugin to make it ultra simple.

So in short, thank you WordPress, you’ve saved my sanity!