Archive for the ‘Web Design’ Category

Use Javascript to Parse a Query String

Tuesday, March 4th, 2008

Most server-side scripting languages, like PHP, come with built-in functionality for reading query strings. Javascript doesn’t have any kind of standard counterpart, but that doesn’t mean you can’t use query strings in Javascript.

With some String functions, you can create your own function to parse a query string attached to the request url and store it in an associative array – just like PHP would for you.
(more…)

Add Custom Loops (Queries) to Wordpress

Sunday, March 2nd, 2008

If you look at your Wordpress template, the thing that drives your page is called “the loop.” That’s Wordpress speak for looping through the result set (the posts) retrieved from the database.

If you wanted to make custom queries, you could certainly do that by diving straight into the database. However, Wordpress comes with some built in functions for helping you query the database and display the results. By using these template tags, you can add custom loops in your template to display other post information.
(more…)

How to Enable Client-Side Caching of Resized Images

Saturday, March 1st, 2008

About a month ago, I wrote a tutorial on dynamically resizing images in PHP. Despite my best intentions, I never found the time to go back and rewrite the script to include server-side caching of the images created.

However, one reader asked if it was possible to enable a client-side cache of a dynamically resized image. It surely is, and it’s very simple.
(more…)

How to Randomize AdSense Ads with Javascript

Friday, February 29th, 2008

I came across this problem on the forums today. How can you randomize which Ad Sense ad to show using Javascript?

The solution, it turns out, is very simple.
(more…)

Widget Bucks CPM Ads a Disappointing Waste of Time

Wednesday, February 27th, 2008

Widget Bucks is a relatively new ad network. At first glance, they appear to be a great alternative to Ad Sense – attractive ads, competitive eCPM rates, and CPM payment for non-US visitors.

After trying them out though, I found one aspect of their network – the CPM ads for foreign visitors – to be entirely disappointing.
(more…)

How to Spoof a Form, or Why Your Form Isn’t Safe

Monday, February 25th, 2008

Forms can create all kinds of security holes in PHP applications. The biggest reason for this is that you can never be sure just what kind of input you’ll be getting.

There are some steps you can take later on to protect your applications from this unknown input. But first, let’s take a look at why you can never trust a user’s input and just how easy it is for someone to spoof a form.
(more…)

RSS Feed: Building an RSS Data Feed in PHP with SimpleXML

Thursday, February 21st, 2008

RSS feeds are a must-have for modern websites. It’s easy enough to make an RSS feed of recent articles in PHP. But did you know an RSS feed can simply be information – not links to articles?

This article will look at how to build a basic feed of data – for our purposes, we’ll consider random quotes. It will also illustrate how to use SimpleXML to build the feed for us.
(more…)

Great Resources: Learning JS, AJAX, and DOM

Tuesday, February 19th, 2008

Over the weekend, I decided it was finally time to learn how to use JS and AJAX. I’d deliberately avoided using JS for anything I could accomplish in PHP – but I admit that I was getting a bit intrigued by the AJAX hooplah.

I found some very useful resources for dealing with JS, AJAX, and DOM, so I thought I’d share them for any other eager learners.
(more…)

How to Only Show the Digg Badge for Popular Posts

Monday, February 18th, 2008

Digg can be a great source of traffic and recognition for tech related blogs. Some people take it to the extreme though, and show the “Digg This” badge on every article they write.

As others have pointed out, this can be counter-productive. People don’t like to read articles that have just one Digg – they seem unpopular.

So here’s a solution: use the Conditional “Digg This” Wordpress Plugin to only show the Digg Badge for articles that have a certain number of Diggs.
(more…)

Fixing a WP Plugin: Per-Post CSS and JS

Sunday, February 17th, 2008

A few weeks ago, I installed the “Per Post CSS and JS” plugin for Wordpress. This allows you to add a custom field to your post and include extra .css or .js files to link to that individual page.

I only realized today – while testing something else – that the plugin had been firing off warning messages because of an oversight in the code. Warning messages annoy me, so I decided to fix it up.
(more…)