Archive for March, 2008

DOMDocument whitespace text nodes

Monday, March 31st, 2008

The DOMDocument is a convenient way of manipulating an XML file. 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”:

    Value

(more…)

Son of a Son of Suckerfish!

Thursday, March 20th, 2008

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…)

What’s your age? PHP can tell you

Friday, March 7th, 2008

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…)

jscalendar 1.0 aqua theme incompatability fix for Konqueror

Monday, March 3rd, 2008

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…)