WordPress Weather Widget (almost)

Posted by Mike

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.

Mike

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…

2 Comments

  • Rafael Pastorelli says:

    Mike, Im a big fan of your york and I'd like to work in this area soon, but here in Brasil we dont have courses for it, and I have to learn everything alone. Can your please give me a hint of wich applications to focus in? Im actually studing maya, blender and visual studio, but id like to work on real time 3d graphics also. Any specific coding language or another tool coud help me more than this ones?
    Thanks in advance. I hope someday i can work with you.

  • Jay Martin says:

    You are right about disabling plugins one by one to solve the missing plugin issue. I'm interested to put together my own plugin like this some day for stock quotes. I think it would be similiar in many ways. Good work and keep up the posts.

Leave a Reply

Your email address will not be published. Required fields are marked *