Super simple Google Maps Smarty Plugin - download the file
Published: 17 May 2011
We've talked about Smarty before, here, and wrote about how we love templating as a smooth way to separate the Vs from your Ms and Cs in an MVC-structured site.
Recently I needed to create Google Maps for Out Takes Film Festival. In the past we've either embedded these directly into the templates for contact pages, or allowed the client to paste in the embed code for locations. Both of these have their drawbacks and I wanted to create dynamic Google maps without requiring the client, who was uploading all the content on a tight schedule, to copy and paste from Google Maps.
There are other plugins for creating maps but they all require the co-ordinates of the location, whereas I wanted to pass the location to Smarty as a human-readable text address that I was dynamically creating for each location based on database content, and have the plugin do ALL the work.
The result is a concise plugin that takes in 3 parameters: the full address of the location, and the height and width of the map you want displayed. It then uses the Google Maps API to geocode that address, and extracts the latitude and longitude from the resulting XML. Then, the plugin returns a string of the embed code to the template, giving you the standard iFrame embedded Google Map of your location, in the desired height and width, with location bubble as well. And as it's basically just a PHP function, you should be able to put this to good use even without Smarty just by changing the way it's called depending on where you're using it.
Sound handy? The file is below. To create a map, in your smarty template you simply write:
{googlemapaddress fulladdress=$fulladdress mapwidth="400" mapheight="350"}
where $fulladdress is a text address (e.g, My House, 34 Something St, Anywhereville) that has been assigned in PHP, and the height and width are whatever you choose to fit within your layout.
Click here to download the zipped plugin file, which you will need to put into your smarty/libs/plugins directory.
Happy coding!
- Rita Langley
Another quake, and this time not so lucky
Published: 03 Mar 2011As most people have seen on TV, the scenes of death and destruction in the central city from the latest quake were horrific. In Lyttelton, which was actually the epicentre, there were casualties from the boulders that came plumetting down the surrounding hills. Our thoughts go to those who have lost friends and family members.
Although technically an aftershock, this quake set a world record in peak ground acceleration (PGA), hitting 2.2 when most buildings are built to withstand 0.8 (previouslt considered quite high). A PGA of 2.2 is equivalent to lifting the buildings 2.2. metres off the ground and dropping them - not something many buildings can cope with.
The cottage where Incodius is based lost the stone wall along the back of the building and the stone chimney that makes up another wall. However, the main structrure is all hardwood and seems solid. We're still working from here.
However, the city is in ruins. Thousands of people have left, many businesses are closed and relying on temporary government support that will only last 6 weeks (maybe long enough to relocate), and the piles of rubble and leaning buildings are only beginning to be demolished. This alone will take months, let alone the rebuild, and the actual inner city of Christchurch (the Red Zone) is predicted to be surrounded by a military cordon for up to a year. Driving along the surrounding streets, this almost seems an optimistic estimate - nearly all the buildings will need to be taken down a re-built.
Incodius is lucky that we have some out-of-town clients, and we'll be attempting to gain more, since for so many local businesses spending money on their web sites is so far down the list of what they need to invest in right now. Hopefully we'll be able to survive here, because it's a great part of the world. The first photos I took after the quake weren't of the destruction, but of an amazing sunset with mist flowing down the crater rim above the town. Yes, we live on a shakey island inside a dormant volcano, and earthquakes are a consequence of this. But so is the awesome landscape. Beautiful + dangerous is a great combination!
-Rita Langley
Hole In The Sky and Adrienne Frater
Published: 02 Feb 2011Over the Christmas / new year break, Incodius created a site to help a good cause - Adrienne Frater and her book Hole In The Sky.
Hole In the Sky is a collection of Adrienne's short stories, which she has published to raise money for the cancer society. Adrienne suffers from a rare form of leukemia and as a writer, has chosen to do this to give back for all the support whe recieved.
We were more than happy to help her out with a site as a contribution towards this cause, and hope that it helps her book reach a wider audience. If you or someone you know needs a site for a good cause too, send us an email on info@incodius.co.nz and we'll see if we can help.
- Rita
HTML special characters tool
Published: 12 Dec 2010When you're adding content to a website, you often need to work around certain characters who have double meanings on the web. For example, the symbol > to a site's users means greater than, or a handy arrow. But the the browser that sorts everything on a web page into nicely formatted blocks, this symbol means that you're about to write some HTML. So, including these characters in a page can cause problems.
The easy way around it is to use one of two PHP functions, htmlspecialchars() or htmlentities(). This will solve the problem if you're extracting content from the database, but if you're wanting to write these characters into a template or blog post, you might need to do it manually.
We whipped up a special character converter for when we want to add <code> to our blog posts, and put it up for anyone to use at incodius.co.nz/htmlcharstool. Enjoy!
Earthquake in Christchurch
Published: 09 Aug 2010We're ok after the 7.1 quake that rattled Christchurch on the weekend. It seems miraculous that no-one was killed considering the destruction around the city!
These kinds of disasters are a short, sharp reminder that if you don't have an emergency kit with at least a torch, radio and basic food and water you'll be in the silent dark while aftershocks ripple around you and you worry about what's going on. My first thought was that the quake must be centered elsewhere, because Christchurch isn't on a faultline (well, wasn't!) and if it's this bad here what about Wellington?
In true web geek style, I don't own a 'wireless' as in radio, only a wireless as in router. But, even without electricty, a laptop and a mobile internet dongle got me online and streaming Radio NZ, and on facebook confirming to people that I was ok and trying to check in that everyone else was. For some reason, this still worked even though the cell network quickly bcame too overloaded for voice calls and texts were taking hours. The same happened in London after the 2007 bombings. This time I was quick enough to get one text through to my mother at the other end of the island before the networks closed out entirely, mainly to check that she wasn't closer to the epicenter than I was and also to say I was ok!
I won't go on about buildings and destruction on our web development blog, but the tech lessons from this are: mobile internet is good in an emergency if you can get it, as it's two-way and letting people know you're ok via facebook or twitter keeps some of the load off the cell network. And as for that network, it WILL overload, so if there's an emergency try to call only if it's urgent, not just to check on people, because people in the thick of it will be trying to use that network to call amublances, find their chidren and so on. It's unlikely the phone campanies will ever have enough in reserve to cope in an emergency, so don't expect to rely on your cell phone!
- Rita Langley



