A-ha! So that’s the problem, now what’s the solution?

Lightbulb Sun
Image via Wikipedia

Ever since the Uniting Church had their website re-done back in 2008, they have had an Activity search in the top right hand corner. And it works great… mostly. There was one big problem – sometimes it wouldn’t return results that should be there. For example, if you type in “greenwood” it would return that there were no Churches within 15km of Greenwood. Despite having a Greenwood Uniting Church in Greenwood. However, if you were to search “Kingsley” – the suburb directly north of Greenwood, it would return Greenwood Uniting Church as the closest church.

When I started at the Uniting Church, this was one of the problems I had noticed with the website. But I didn’t know what was causing the problem. Until one day, when talking about it with my manager, she said that if you typed the state as well, you got the correct result. A-ha! my mind went, so that’s what the problem was.

See, our activity search uses the Google maps API, and there’s more than one Greenwood in Australia. Likewise, there’s more than one Mount Pleasant. So what was happening was that the search would find the first Greenwood, which was invariably not in WA. But our users, coming to the website of the Uniting Church in Western Australia would assume that the activity search would search WA first. Having it search other states is completely useless to us, but there seemed to be no setting in the plugin that we were using to set it to only search WA.

Knowing that if you added “WA” to the end of the search it worked correctly, the simplest way I could think of to solve the issue was to append “, WA” to every search that didn’t end in “WA”. Now, while I work on the website, I’ve had no formal training. I taught myself HTML and CSS, and working with WordPress has taught me a bit of PHP, but in terms of coding something like this I needed to know JavaScript. I had a search around the internet to see if someone had a similar problem, or a solution that would work. I think my first effort ended up breaking the search completely. I talked to a friend who actually codes websites for a living, and he came up with some code that he thought would work, but wasn’t certain. It didn’t quite work, so I posted it in a forum and asked for help. They helped me out by pointing out the errors (needed a capital letter instead of a lowercase letter, and a ‘ instead of a “).

So now, if you search for “Greenwood” you will receive results for “Greenwood, WA” and find the details of the Greenwood Uniting Church. All I needed was for someone to discover why it was doing what it was doing, and my A-Ha moment came as to how to fix it.

Postaday2011 links

Advertisements

Author: Ben Clapton

I'm an Officer in The Salvation Army, currently appointed with my wife as Corps Officers at the Rochester Corps in country Victoria (20 minutes out of Echuca). I play violin and guitar, amongst many others, and love golf and running.

1 thought on “A-ha! So that’s the problem, now what’s the solution?”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s