Iain Urquhart

{entry}

Some New Work…

4 Comments

I just pushed live some work that has kept me busy for the last few weeks and I thought some of the behind the scenes workings might be worth a share.

The northlandnz.com website is the official tourism site for the region of Northland, New Zealand. It’s where I call home - it’s a fabulous part of the world and I get really excited every time there is an opportunity to work on the site. Today I just relaunched the accommodation section which has been a couple of months in the making.

The scope of the upgrade was primarily to move from a deprecated and soon to be disabled API for sourcing the accommodation listings. The national tourism organisation (Tourism New Zealand) has recently updated it’s API and has given each regional tourism body access to its spanky new database of tourism industry data. For Northland, this means access to a database of close to 1000 tourism related businesses which are continually kept up to date by industry.

Fetching and syncing the data

The API itself is pretty straight forward - the main head scratch was how to store it in ExpressionEngine. A lot of the taxonomy at their end is keyword/tag based and it doesn’t have heirarchy or structure. I don’t really like this much and is my main criticism of the newzealand.com website - it’s quite easy to find yourself overwhelmed with keywords/tags dominating the UI.

I decided to take advantage of the ExpressionEngine Channel Entries API and store everything as natively as possible with as few 3rd party field-types as possible. To introduce taxonomy I used a mix of native categories along with the Solspace Tag module. I knew that down the line, Solspace Super Search would be a key player so I made sure to store the data in quite conventional fields that were fully supported by Super Search. Matrix is used for the image galleries along with Playa to build some relationships between businesses and places.

Areas vs Towns/Cities

One problem which I really wanted to overcome with this work was to break away from the restriction of filtering only by town or city. In Northland for example we have The Bay of Islands, The Tutukaka Coast, The Hokianga, Bream Bay… I could go on. These are not citys or towns but geographic areas that people ‘know of’ and go looking for information about. The marketing information that tourists receive (typically official tourism guides) break down regions into these bite size areas so people are much more familiar with the district names than they are with the actual town names.

I needed to come up with a way to create arbitrary places like “The Bay of Islands” so I built the Pretty Polly field-type. Put simply, it’s a polygon field for EE which lets us define an arbitrary area and give it a name :)

Here for example is ‘The Bay of Islands’ loaded into ExpressionEngine.

Every time we sync our database via the Tourism New Zealand API, we simply run each incoming lat/long past our polygons and assign Playa relationships between accommodation providers and places. It took me a while to find a suitable algorithm for calculating whether a given lat/long was within a polygon, but eventually I found (the imaginatively named) polygon.php class. Out of all the classes/algorithms I tried, this was the only one that returned good results after a lot of testing.

Never more than 40km from the coast, and what a coast

One thing I really wanted to show off in the design was Northland’s stunning coastline. In this region of New Zealand you’re never more than 40km away from the ocean so it made sense to use Google maps satellite imagery at the forefront.
I’m really happy with the end result on detail pages.

Next on the list

The way I work is to work fast and fire through the initial requirements as quickly as possible. As soon as the in-development product is ‘better’ than the existing site - we replace it. All future enhancements are then made after reviewing and measuring our work through tools like Google Analytics and industry feedback - not when the budget is spent and there is little opportunity left to be proactive.

The section still has a many rough edges which I’m ironing out but overall I think it’s a solid base going forward. I really want to ajax up the category, location, and map filtering so there are no page refreshes and also take advantage of the HTML5 history API - but that’s going to take me a while and there’s going to be a lot of learning involved to tick off those boxes, can’t wait :)

Comments for this entry


GDmac
2012 02 27

Nice write-up. Interesting to see how EE is used for more data-integration type of applications than merely publishing articles or a blog.


Ryan Battles
2012 02 28

Thanks for taking the time to write this up.  It is entries like this that keep expanding my thoughts about what EE can be made to do.


Narration
2012 02 28

Iain, quite enjoyed that.

Very attractive work, and I hope the tourist board appreciates who they have in you, arranging the work in this way. It will get them the best.

Regards,
Clive

↑ Back to top