Archive for ‘Software Development’

Conditional page/post navigation links in WordPress

Sunday, November 18th, 2007
Update: This post has been replaced with an updated version.

While creating a new theme for this site, I added some CSS styling around the page/post navigation links.

For example, in my index.php page, I have the following HTML/WordPress code:

<div class='navigation'>
  <span class='older'><?php next_posts_link('&laquo; Older Entries') ?></span>
  <span class='newer'><?php previous_posts_link('Newer Entries &raquo;') ?></span>
</div>

And the following CSS code:

.navigation {font-size:.7em; background:#353535; height:16px; margin:0 -16px 8px -16px; padding:8px 6px 0px;}
.navigation span {margin-top:-4px;}
.navigation .older {float:left;}
.navigation .newer {float:right;}

Everything looked great, until I brought up a page that did not have a previous or next link. The styled navigation div was still there, but there was nothing in it. So, I set out to conditionally display the navigation div if either a previous or next link existed.

Read the rest of this entry »

SimpleModal v1.0 released

Friday, October 19th, 2007

While developing a recent project at work, I had the need to display a modal dialog. I started using jQuery recently and so I started by looking for a jQuery modal dialog plugin.

I did find a couple of existing ones (jqModal and BlockUI), but neither did exactly what I was looking for. So…I decided to take a crack at writing my first jQuery plugin.

It has been a great learning experience and has caused me to become an even bigger fan of jQuery. I’ve used a few other JavaScript libraries (MooTools, Prototype, etc), but jQuery is something special.

So, if you have a need for a modal dialog…be sure to check out SimpleModal.

View Demo

Traffic charts for my commute

Sunday, September 9th, 2007

When I changed jobs, my commute changed from mostly surface streets to mostly highway. I-80 is notoriously congested and I wanted to strategically plan my commute to avoid as much traffic as possible.

I started by watching traffic online and then found Traffic.com, where I could create custom drives and receive alerts, etc. Pretty cool…but I wanted a way to SEE traffic trends, so I designed a way to get data from Traffic.com and to then display that data in a graph.

Traffic.com offers a RSS feed, so my plan was to use data from that feed to generate the graphs. So, I signed up at Traffic.com and created two custom drives; “Home to Work” and “Work to Home”. Next I created a database and tables to hold the data:

Read the rest of this entry »

PHP Bug - glob(), GLOB_BRACE, and Windows paths

Sunday, September 2nd, 2007

I stumbled upon a PHP framework called Kohana, which is based on CodeIgniter. I’ve used CI a bit in the past and thought I’d give Kohana a whirl. I downloaded the latest code and tried to run it on a Windows XP machine.

Well, when I brought up the site, I got an error:

Fatal error: Unable to locate the requested file, log.php in <system_path>/system/core/Kohana.php on line 408

After a lot of digging, I found that there was a glob() call that was not behaving correctly. I narrowed it down to what I believe to be a bug in PHP with the glob() function, using the GLOB_BRACE flag, and using a pattern that includes a colon (as in {c:/firstFolderToCheck,c:/secondFolderToCheck}).

Assuming it turns out to be valid, I’m surprised that it hasn’t been found/reported before…