Archive for March, 2008

31 Mar

DOMDocument whitespace text nodes

The DOMDocument is a convenient way of manipulating an XML file. While this is for PHP, I’ve come across some great parsers for use on a business iphone using lib2xml but we leave that for another day. One issue I ran into was the fact that when loading an XML file, DOMDocument treats the tabs and spaces which make the XML readable as empty text nodes. This presents a problem when you try and traverse the DOM by using attributes like firstChild and nextChild. For example:

Here is the XML file, “example.xml”:

      <root>
           <tag>Value</tag>
      </root>

(more…)

20 Mar

Son of a Son of Suckerfish!

I’ve been using the lovely Son of Suckerfish method to make drop down menus for years now, and it is a very robust way to make them. The one criticism (the word criticism is an overstatement really…) I have is that for every sub-menu level, you need to add to the CSS in order for that to show. Now, it’s not a really big inconvenience… how many sub-levels do you need anyway… but wouldn’t it be nice if we didn’t have to do that? I have made a very small change to the CSS and Javascript that takes care of this problem. (more…)

07 Mar

What’s your age? PHP can tell you

I was looking around for a simple function or something that calculates the age of a person with a given date. I figured there must be something that did this natively in PHP, but to my surprise…. no.

Further looking around found some overly complicated (not “complicated” but just way too long for what they do) scripts to calculate an age. In the spirit of easy minimal code, I did it in two lines :

1
2
$ageTimestamp = time() - strtotime($date);
$age = floor($ageTimestamp/60/60/24/365);

So…. quick explanation for those that are learning the ropes …. (more…)

03 Mar

jscalendar 1.0 aqua theme incompatability fix for Konqueror

I love jscalendar… it’s dead easy to use, does what I want, is very flexible, and looks nice. Anyone that has a better free option, please let me know. MooTools (along with other JS libraries) have some cool implementations, but this script does stuff that others do not do.

When IE7 came out there was a bug in the calendar which essentially rendered the free version useless and therfore had me thinking of alternatives. Thankfully, this was soon resolved and I have been using jscalendar to this day.

A problem I came accross today is that the very cool aqua CSS theme that comes with the calendar didn’t work properly on KDE’s Konqueror. (more…)