Posts Tagged ‘Wordpress’

WordPress Links Page

Sunday, April 12th, 2009

Today I was playing around with the blog, and decided that the Blogroll I have up needed some improvement. Unfortunately I couldn’t find anything on the Internet that did what I wanted (ie the lazy way failed), so I had to dig into the theme files for WordPress and make something up myself.

After doing a bit of research, I found out two handy things. The first is that WordPress supports Page Templates, which is a fancy way of describing how a page looks. Static pages (About Me, Contact Details, etc) have one template, and posts (the main blog content) have another. They are similar templates, but not identical. The second handy thing I discovered is the internal WordPress function wp_link_bookmarks(). Putting these two pieces of information together, I decided the easiest thing to do was create a ‘Links Page’ template, and then use this template for an empty page. The wp_link_bookmarks() function would dynamically generate my blogroll on each page view.

I had to play around a bit with the parameters to wp_link_bookmarks() quite a bit in order to get it to display properly; the function kept insisting on placing bullets on the category names as well.

You can download the page template file from here, if you wish. It should work with most WordPress themes (if it doesn’t let, me know). To use it:

  1. Upload the links.php file to your WordPress installation, in
    /wp-content/themes/<theme-name>/
  2. Create an empty static page in WordPress, give it a name (Blogroll or Links Page or whatever), and disable comments (the template won’t look pretty with comments enabled).
  3. On the right-hand side of the page editor, use the ‘Page Template’ option and set it to ‘Links Page’.
  4. Publish the page. Enjoy.

Hack of the Year

Sunday, April 12th, 2009

As you might have noticed, I’ve switched back to using WordPress (again), and managed to dig up all my old blog posts (most of which are utter crap). At the moment I’m using the lighttpd web server, and I had to play around a bit with mod_rewrite in order to get the pretty URLs working. In the end I got lazy and just settled for a hack I found on the Internet. And as a hack, it’s pretty epic.

server.error-handler-404 = "/index.php?error=404"

What it does is thus: when you click on a page in the blog (such as http://www.jackscott.id.au/2009/04/hack-of-the-year), it searches for a folder named 2009 on my web server. That doesn’t exist, so it produces an HTTP 404 error (which means the page doesn’t exist). The rule above (pasted into the lighttpd configuration file) redirects all 404 errors to the index.php file. And this file (as the WordPress main file) just happens to know where to find the page requested. Truly a monumental hack.

The only downside to using this configuration is that Statpress (my favourite WordPress plugin) no longer works properly. It reports the correct number of page views and so on, but all pages requested are listed as ‘error=404‘. Not very useful when you want to see which pages are viewed the most.

But nevertheless, a pretty cool thing.

Blog Moved

Thursday, January 29th, 2009

As of whenever the DNS updates catch on, my blog and email are now being hosted from my home server, jackscott.homedns.org. Nothing much will actually change, except that’s it’s technically a fresh installation of WordPress.

The rest of my server is a different matter though. I’ve added two 512MiB sticks of memory to my server, giving it 1GiB total. Compared to the 128MiB that was in it before, memory is bountiful. Which is a good thing, because I’ve switched to using the Apache webserver (which consumes a bucketload of RAM). I was using Lighttpd before, but setting up PHP support on that proved to be a pain in the neck. I’m sure it can be done, but I don’t have the patience to sit down and do it.

Configuration of the Cisco router was going swimmingly up until the point where I had to set up network address translation and port forwarding. I’m not confident with any of the configuration as far as those aspects go, and I’m unwilling to pull my server offline to test whether ‘it might work’. I’ve basically painted myself into a corner, but I’m confident with a bit of reading I can get it up and running.

In other news, I’ve left my job at Principal Computers. I’m in the middle of a week and a half doing nothing, and next Monday (the 2nd of February) I fly to Berlin (via Melbourne, Hong Kong and London) for 19 days of sightseeing and wintery goodness. When I come back it will be straight into a science degree at the University of Tas. The units I’ve chosen for first semester are Discrete Mathematics with Applications 1, Calculus and Applications 1A, Economics for Business and Programming and Problem Solving. Sounds like fun…