Wordpress Weather Widget (almost)
Over on the right there you should be seeing a little widget-like thing showing the weather forecast for Lovely Leitrim. (UPDATE: currently disabled). It’s using my own TV graphics-style Weather Icons which you can get here.
I don’t know exactly (yet) how to make it into a downloadable widget that other people could use on their own sites, but if I get time I may investigate how to package it up. At the moment it’s just hard coded into a regular text widget. And it’s also hard coded to pick up the weather forecast for Carrick-on-Shannon, so I expect the appeal might be… er… limited.
The inspiration for this came from seeing articles like Using Weather Data to Change Your Website’s Appearance through PHP and CSS and of course, the BBC Weather site which displays different graphics depending on the weather forecast.
The main thing I wanted to learn about was just the basic process of getting and parsing a feed and using some of the data it contained to pop a weather symbol on my site – there were plenty of sites out there offering different solutions, but the php classes from Marco Voegeli were a great starting point.
I discovered quite a few useful things while trying to put this together. Probably the most important in the end was to check your hosting company’s firewall settings…
I’d had the basic code working fine for AGES and was testing happily using MAMP on my local Mac, but every time I tried to put it live on the server it killed the entire blog and all my existing widgets vanished from the admin page. That usually happened right before Wordpress froze up completely.
Anyway, the bottom line is I needed to contact my host (Supanames) to get them to allow me to contact the remote website to access the Weather feed. There’s a link in MyPanel called ‘Firewall Rules’ and a form to send a request to the engineers to enable connections to a particular URL. Which once again, all happened very promptly, so full marks again to Supanames support.
Also, if ever you lose all your widgets from your Wordpress Admin screen, I’d recommend disabling your plugins one by one until the list comes back, then remove (or edit) the offending widget, and then re-activate the plugins. I know that’s probably fairly obvious to most, and may not always solve the issue, but it’s still a good starting point.
UPDATE: March 2010
This widget had been running just fine for nearly a year, but today something went screwy and it killed the whole blog. I’ve removed it for now, pending further investigation. It’s a bit tricky because I can’t view the blog to see even what kind of error it’s causing…