Monthly Archives: February 2008

WordPress and Page Templates

I’ve been doing a lot of work recently on my employers website. I had been using Joomla as a content management system, but it was overkill for what I wanted, and I found that it wasn’t the most stable of platforms. (Frequently, and for no apparent reason, pages that were published would suddenly become unpublished.) It was more hassle than it was worth, so I got rid of it and installed WordPress instead.

I decided on WordPress as I’m familiar with it, and with a couple of tweaks to the settings it no longer resembled a blog. It was relatively easy to design a simple template, and get the site up and running, but I did have one major issue. I needed an Events page and a News page to display what would traditionally be considered blog postings . The idea was that each page would be linked to one specific category and one category only. In other words, posts in the Events category would only appear on the Events page and posts in the News category would only appear on the News page.

While WordPress does allow you to specify a static page as your “Front Page” and another page as a “Posts Page”, there doesn’t seem to be an easy way to force WordPress to use two Post Pages, or to restrict a Post Page to just one category. One idea I played around with was to edit the header.php file and manually add the links to the actual categories. WordPress would then display the resulting page using archives.php. It’s then a simple enough matter to edit the file to display the posts as needed. It’s a quick solution but it does pose two problems:

  • The links are hard-coded into the header.php file. If for some reason the links are changed, or if the theme is updated, then the links have to be manually changed again.
  • Using links in this manner doesn’t give the same flexibility as allowing WordPress to manage the navigation, Pages and Posts.

The answer I found was to use Page Templates. By putting the code to retrieve the posts from each category into a Page Template I was able to bypass hard-coding the links and I could display only the category I needed on each page. If your interested, you’ll find a sample Page Template here.

My next thought is to expand this into a plugin in order to make easier to select which category should be displayed, and which page it should be linked to. I’ll have to think about how to go about it some more though.

Finally – Mac OS Update 10.5.2 is here

It’s been a long wait for Leopard users, but 10.5.2 is now available from software update or from the Downloads section of the Apple website.

The full list of fixes contained within the update is available here.

At 180MB the update isn’t as large as originally predicted.

Update: After downloading the 10.5.2 update, there’s another update available via Software Update – Leopard Graphics Update. The update is also available from Apple Downloads here.

Setting Up Movable Type 4 on a MAMP Server

Recently my hosting provider, Blacknight Solutions, requested that bloggers using WordPress use the WP-Cache plugin to reduce the load on their servers. Michele at Blacknight has been somewhat critical of WordPress in the past, mainly due to it’s inefficient SQL and the resultant high number of database queries required to generate even a simple page. Based on this Michele moved over to Movable Type 4, and despite a few teething problems, he seems to be quiet happy with it.

As part of their control panel, Blacknight provide the handy Installatron Script Installer, however, there is no installer available for MT, so users have to manually install it themselves. Unfortunately my upload connection is so bad, that it me takes hours to upload the approximately 20 MB of MT install files. As I use MAMP for local site development, I’d thought I’d have a go at a local install of MT.

Because of where MAMP is installed, it’s not a straightforward process, there are a couple of “gotchas” along the way. So for those of you interested in performing a local install of MT4, here’s a quick HOWTO.

Before you start, you’ll obviously need MAMP Server, and MT4. You can grab MAMP here, and MT4 here.

Part I: Getting Ready To Install Movable Type

  1. Once you have downloaded the MT4 ZIP file, extract the files to a folder of your choice.
  2. Within this folder, you should now have an MTOS-4.1-en folder.
  3. Open this folder and locate the mt-static folder.
  4. Move the mt-static folder to /Applications/MAMP/htdocs/
  5. Open a new Finder window and browse to /Applications/MAMP/cgi-bin/
  6. Create a new folder, and name it mt
  7. Move the remaining files in the MTOS-4.1-en folder to /Applications/MAMP/cgi-bin/mt/

Part II: Create a SQLite Database

Before starting the Movable Type installer, you need to create a database in which to store your blog settings, posts etc. While the MT developers recommend that you use MySQL for your database, an additional Perl Module is required otherwise MT will not recognise your MySQL server. However, as this will be a local install, SQLite should be more than enough for your needs. (If you really need it, the required module is DBD::mysql which can be found here, but be warned installing it is problematic and time consuming).

  1. Start the MAMP application and click the “Open Start Page” button, or alternatively, type http://localhost:8888/MAMP/ into your address bar.
  2. Click the link for the SQLiteManager at the top of the page.
  3. Type in the name of your database, and select Version 3.
  4. The full path to the database file also needs to be provided. In this example, I’ve called my database mt4, but you’re free to call it whatever you wish.
  5. Note that the path to your database will be /Applications/MAMP/db/sqlite/[your database name].db
  6. Click the Save button, and your database will be created.

Part III: Installing Movable Type

Now that you have all the MT4 files in place, and your database has been created, you’re ready to start the Movable Type web-based installer.

  1. Open your browser, and type in the following address: http://localhost:8888/cgi-bin/mt/mt.cgi
  2. The installer will tell you that the mt-static has either been renamed or moved and will request both the Static Web Path and Static File Path to the folder. Enter the following paths:
    • http://localhost:8888/mt-static
    • /Applications/MAMP/htdocs/mt-static
  3. Click the Begin button and the installer will confirm that the paths you have entered are correct.
  4. The next step brings us to the database connection setup page. Here is where we’ll tell Movable Type where our database is and how to connect to it.
  5. You’ll note that the only database connection available to us is the SQLite Database and once again we’re being asked for the path to the database. This is the exact same path that you entered in Step 6 of Part II above:
  6. In order to proceed, you’ll need to Test the Connection.
  7. Once MT can talk to your database, then Continue onto the next step -setting up your email.
  8. From the drop-down, select Sendmail and accept the default Sendmail path. Enter your email address and click the Send Test Email Button.
  9. The next step is to set up the admin user and password.
  10. The final step is to create your first blog!

Heading for Cardiff

It may be a bit premature considering that Munster still have to get past Gloucester and then either Saracens or Ospreys, but I’ve booked my trip to Cardiff for the Heineken Cup Final at the end of May.

The quarter-final against Gloucester is going to be a much tougher game than most people believe – beating Gloucester and winning through to the semi-final will be harder than getting to the final. Though there are no easy games at this stage of the Heineken Cup, I prefer our chances against either Saracens or Ospreys.

No matter what happens next April/ May, I’ll still be in Cardiff come the 24th May. I’ll be much happier if Munster are there too.

As a post-script, this will be my first ever foreign “holiday”. In this age of cheap air fares, most of my friends find it amazing that I’ve made it to the age of 31 without leaving the country.