Category Archives: Coding

No More CSS Hacks: PHP Browser Detection

You can’t make your page render correctly in every browser. It just isn’t possible. Between several versions of the bug-ridden Internet Explorer (why can’t Microsoft just switch to Gecko or WebKit?) and a sprinkling of older browsers, there are too many bases to cover. Internet Explorers 6 and prior are notorious for their bad CSS implementations (IE7 is better, but it still has a ways to go), and if you tweak your CSS to look right in them, chances are you’ll create another problem somewhere else. When does the endless cycle of fixing things end? When you give up and say “it’s just not going to work in all browsers.” Now, you don’t want to give up too soon, since there are still a lot of people on IE6, but you have to know when to call it quits.

And don’t forget about mobile browsers. Sure, their improving, like Apple’s mobile Safari browser on the iPhone, but it’s still a lot easier to use a mobile-specific version of a site than zooming and scrolling around on the tiny screen.

As usual, PHP has a solution. That solution comes in the form of the global variable $_SERVER['HTTP_USER_AGENT']. It holds a string that contains a bit of information about the browser and platform a user us using. By searching through the string, you can figure out what browser your users are browsing with, and write-in the right code depending on the browser. You can do this in as simple, or as complicated, of a way as you want.

Continue reading →

Automatic Date-Based Template Edits

Have you ever wanted to use a different stylesheet on a specific date (a holiday, perhaps) show/hide part of your template on a certain date? One example is RSS Awareness Day. I’d suggested that on May 1st, in observance of RSS Awareness Day, some…

roScripts – Helping Programmers Program

roScripts is a blog/forum/Digg-for-scripts. Their “articles” section has several categories worth of coding tutorials (PHP, Flash, AJAX, HTML, etc). Then they have the “scripts” section, where you can easily find pre-made scripts to suit your purposes. The interesting part, though, is that they’re sorted…

jQuery/Firefox Bug

When I was developing the NTugo webtop, I did a bit of work with jQuery and noticed an odd bug. Using the show() and hide() functions on divs, there is one instance where the body’s background image is disrupted by the animation. It only…

Book Rotation: Randomly Display Your Favorite Books

This tutorial will teach you how to build a “Book Rotation.” On pageload, it picks a random book from a list of your favorites, and displays it’s title and cover, linking to it’s Amazon page with an affiliate link. You can see it in…

Merging RSS Feeds With SimplePie

Have you played around with SimplePie? If not, start experimenting. SimplePie is an amazingly useful file you include in your PHP scripts so you can parse RSS feeds. It’s fast, it’s powerful, it’s easy to use, and there’s a lot you can do with…

Customize Feedburner’s Subscriber Count Chicklet

Are you using Feedburner? North X East has an excellent tutorial on customizing the Feedburner Subscriber Count Chicklet. Using a WordPress plugin, and a bit of CSS, you can go from the default chicklet to something totally different. You didn’t honestly think you were…

PHP Includes

When you make changes to your site (add another link to your navigation, completely change the layout, etc.) you probably have to make changes to all 172 HTML files. Right? Do you wish you could just change it once? You can (if your host…