2007 June

Implementing The Real Ultimte Front Page

Previously, I briefly illustrated how using a home.php file can allow you to build a custom layout to your WordPress blog’s home page. However, I didn’t really document it well enough for the casual WP user to implement by himself. For the unknowing of my readers, here is a guide to using my (really Rudd-O’s) discovery on your site.

If you already understand the concepts behind this, skip to the download link.

Let’s take a look at Rudd-O’s code again. Try to figure out what it’s doing:

1: <?php $homepage = get_settings('siteurl')."/home/";
2: global $wp;
3: $wp_received_argument = false;
4: foreach ($wp->query_vars as $k=>$v) if ($v) $wp_received_argument = true;
5: if ($wp_received_argument) require(TEMPLATEPATH . "/index.php");
6: else { wp_redirect($homepage);
7: exit(); } ?>

Line 1 gets the address of the blog and adds what we would use to access a static page with a slug of ‘home’.

Line 2 brings in the $wp object, which allows us to figure out if there are any parameters in the URL that we need to work with.

Line 3 sets a simple boolean value of ‘false’ to a variable that we will use to determine if we have recieved any parameters.

Line 4 looks at the $wp object and asks it if there are any parameters. If it finds any, then we set $wp_received_argument to ‘true’, and we will use that in the next line.

Line 5 is where the magic happens. If we have parameters, like the page number variable, then we will load the regular index.php template which will show you the normal blog page. Otherwise, we will continue to line 6 and 7.

Line 6 will run if we don’t have any parameters, which means that we want to show our special home page. We will send a redirect to the browser telling it to go to our static page. Then we quit running this page, since there is nothing more to do anyway.

This is a relatively simple concept. Rudd-O mentioned in his original article that one should add a link to /[wp-root]/page/1 somewhere, like in the header along with the page links for example. What that will do is give WordPress the parameters we need to have the blog listing shown. If you need help adding this link, leave a comment below.

Here’s the fun part. My hacks to Rudd-O’s code will replace the redirection of the original code. All HTML and PHP content is placed within home.php. Now that we are including our content in a straight-out PHP file, and not going back to the database to retrieve a page (via the WP Loop), you can even add a real mini-loop to your front page! You can do whatever layout you want with home.php now. (See my home page, which has the mini-loop, a list of categories, and my Flickr photostream, for an example).

Now that we understand what Rudd-O’s code accomplishes, it’s up to you to use your imagination. Until recently, my email that came upon request included some basic instructions, which read something like this:

Attached is a well-commented version of home.php. Use it to set up your custom layout, but don’t upload it yet.

In order for this to look and function properly on your site, you will need to adapt it to your theme. You will have to make the portion of home.php before my table-based layout look like the code in index.php from the top of the file to just before the loop, and from just past the loop until the end of the template. Remember to close the else statement with a right curly bracket.

Also, you will need to add the /page/1 (or ?paged=1 if you aren’t using pretty permalinks) link to the page list in header.php, which should include code to dynamically change the highlighting of the Home and Blog links.

For those basically familiar with PHP, HTML and some of the simpler CSS concepts, adapting the sample home.php file I am providing should be somewhat easy. If you don’t have such keen skills, you can review the W3Schools’ tutorials on HTML and PHP for a bit of help. (Sorry folks, these days I can’t handle doing the editing for everyone, although I wish I could.)

If you are convinced that you want a home page with a custom layout for your WordPress blog, I have provided an older version of my layout, plus all of the associated logic basedon Rudd-O’s code. As noted above, you will have and want to do lots of tweaking with it to make it look good, so grab the download below, and hack away.

 Download sample home.php layout »

Western Digital My Book 250 GB Essentials Edition

Today’s ever-digitalized world is using ever-increasing amounts of storage. Once I downloaded the Adobe Premiere CS3 preview / beta, I really discovered this for my self, and followed up on that with a copy of VMware Server (which I run Ubuntu Linux in). Turns out my measly (relatively) 80 GB internal SATA drive just isn’t big enough to keep up with the current storage demands.

Western Digital My Book Essentials

After finding a real steal on Western Digital’s My Book Essentials Edition at Circuit City, realizing it was after a mail-in rebate, buying the smaller 160 GB drive, at Best Buy, returning that one and finally getting the original 250 GB drive at Best Buy with a price match, I got my hands on yet another addition to my “studio”. I felt like an idiot for not bringing a Circuit City flyer to Best Buy with me, but that’s how idiots roll.

The drives enclosure is bigger than I anticipated, but it still looks sharp. Western Digital advocates that their My Book drives can be placed in a bookshelf or laid on their sides and stacked vertically. The little green circle on the front of the case indicates power and disk access status. Pressing the center of the circle powers on or off the drive. Unlike many other devices these days, the WD drives comes with a normal size power adaptor.

Setting up the drive was a snap. After connecting it to an open USB port on my computer, an Autorun dialog popped up, prompting me to do install software. I neglected to choose to install anything, but it appears that a Western Digital drive utility made its way on my machine anyway.

Regarding performance, the drive is definitely not as fast as my internal SATA drive, but that’s a given. Accessing files is pretty snappy, although occasionally the drive has to spin up after going into standby (after about ten to twenty minutes).

This new drive will serve as a non-performance-critical repository for most of my digital media (as well as my huge catch-all download folder), and to archive files needing the speed of my primary drive after I finish working with them (like video footage). For now I will keep my VMware images on the main drive.

Typically I’m very frugal on computer upgrades – and the 69.99 USD really shows how good a deal this was. Needless to say it was worth every penny.

Help Askimet – Don’t Use Recheck Queue Option

According to some friendly message present within a part of the Askimet interface, comments that you mark as spam will be submitted to the free service to help make it better. Most people don’t realize, however, that when they click the Recheck Queue for Spam link in the Moderate Comments screen, they are most likely just having Askimet filter the spam comments over again. Help Askimet out buy clicking Mark all as spam, and submit those spam comments to the folks at Automattic to make the service smarter.

Regents – Yet Again!

The time of year has come – my first NYS Regents exam will be administered tomorrow. This year I am taking the Global History, Comprehensive Hebrew (as a language), and Chemistry / Physical Setting tests. Overall I don’t feel too prepared for any of them. However, as my dad says:

If you aim low, you will almost always succeed.