Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder Common's Avatar
    Join Date
    Jan 2009
    Location
    Glasgow, UK
    Posts
    132
    Thanks
    16
    Thanked 13 Times in 13 Posts

    A good, simple weather plugin?

    Hi there

    I'm trying to get some basic weather information to plug in to my website and display in the header, similar to what you'll see in the top left corner of The Londonist: http://londonist.com/

    However looking online, all I can find is big graphical weather widgets and such which offer absolutely no customisation. Literally all I need is plain text of temperature and weather conditions in my specific city (Glasgow, UK) which I can then style.

    Does anyone know of a decent API or such which will allow me to do this? I'm happy to pay if need be.

    Many thanks

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,371
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    How many visits per day do you expect on your site?
    Some have limits to accesses per day.

    Is the info below the correct location?

    “Glasgow Uk”
    District-County: Strathclyde
    Province-State: Scotland
    Country: United Kingdom
    WOEID: 21125

    Knowing that, your "Where On Earth Am I ID" is 21125.

    That WOEID is used by Yahoo to get their weather feed:
    http://developer.yahoo.com/weather/

    You now need to get a set of graphic images for every icon (clear, cloudy, rain, etc).
    Note that each condition code has a number. It would be easier of you named your icons like: c0.png, c1.png, c2.png ... etc. so the number matches the condition.

    When you get those, you'll then need a PHP script to get your weather data and display the correct icon. I can help you with that, but is your website ready to use PHP? Is your main page called "index.html" or "index.php"? Is your site a hand-made web page, or part of something else, like WordPress?

    Can you give us a link to your website?

    EDIT:
    Just so you know ... here is a list of what you can get in real time. This is Glasgow, UK ... a working PHP example (testing concept):
    http://www.catpin.com/glasgow.php

    The very last item in the list is the creation of your widget .. I don't have icons yet.


    .
    Last edited by mlseim; 10-24-2013 at 05:30 PM.

  • Users who have thanked mlseim for this post:

    Common (10-24-2013)

  • #3
    Regular Coder Common's Avatar
    Join Date
    Jan 2009
    Location
    Glasgow, UK
    Posts
    132
    Thanks
    16
    Thanked 13 Times in 13 Posts
    Hi mlseim

    Well first of all, thanks so much for such a wonderfully detailed response! Yes, that is indeed the correct Glasgow.

    My website can be found here: www.getoutglasgow.com

    On a good day it receives maybe 300 unique visitors, so I don't think we'll be hitting any usage limits.

    I would love if you could give me an idea of how I would handle that data with PHP. I'm actually relatively well-versed in PHP, however I do not often work with APIs of any variety so am struggling to figure out exactly how to grab and echo this data.

    Thanks again!

  • #4
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,371
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    So you have a WordPress site, that makes it a little bit tougher.

    I assume you've already looked for some existing WP plugins? https://www.google.com/#q=wordpress+weather+plugin
    It would be easiest if you found a plugin you like, but you still can create your own weather 'widget' if you wish.

    You'll have to first determine where you want it to appear. On the top of your sidebar?
    Just let me know where it will appear, but don't program anything at this time.

    Next, have you ever customized your theme? Do you intend on ever uploading new revisions of your theme called "Genesis"? I think that's the name of your WP theme? I ask this because you'll be modifying a script in your theme directory, and if you update the "Genesis" theme it will be overwritten.

    1) Create a new directory within "genesis" ....
    Call it 'weather' if you want ....
    wp-content/themes/genesis/weather/

    2) Upload all of your condition icons to that directory. You'll need about 50 of them as described on this page: http://developer.yahoo.com/weather/
    See the 'condition codes'. Those icons will be a set of PNG or GIF images, one for each condition.

    Let me know when you get that far, and how you named those icons. It would be nice of part of the icon filename had the 'condition code' in it, so it can be identified.

    Here is what I mean by a set of condition icons:
    https://www.google.com/search?q=weat...w=1440&bih=770

    3) When you have the new directory done and the icons uploaded, let me know, and I'll post the PHP script that will be going into that new 'weather' directory.

    And also verify that this is the actual name of your theme directory: wp-content/themes/genesis/


    .
    Last edited by mlseim; 10-24-2013 at 08:51 PM.

  • Users who have thanked mlseim for this post:

    Common (10-25-2013)

  • #5
    Regular Coder Common's Avatar
    Join Date
    Jan 2009
    Location
    Glasgow, UK
    Posts
    132
    Thanks
    16
    Thanked 13 Times in 13 Posts
    Brilliant thanks.

    Ok, so I think I've done things slightly differently, and have created a new widget in my wp-content/plugins folder, activated it and it's ready to be dropped into the sidebar once it's ready (tested it out and it's showing just fine). I have had a good look through available weather plugins but none have offered the customisation I need. The weather is going to be a small part of the information which will be a kind of "at a glance" at a few different pieces of information about today in Glasgow.

    I'll be getting round to either making or sourcing a suitable set of icons this weekend, and I will name them precisely as you have suggested: c0.png, c1.png and so on.

    If I've misunderstood and the code does need to be in wp-content/themes/genesis that's no problem at all, I have modified the Genesis theme extensively since adding it to the website so yeah, no worries at all about modifying source code, I won't be updating this theme until the next time the website has a full overhaul.

    Thanks again

  • #6
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,371
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    Below is the PHP script to display the minimalist weather conditions. The part at the bottom of the script (the output) uses in-line CSS, so that is where the tweaking will be.

    Also, the path to the icons ... that will need to be determined. You'll see the bottom part of script where you'll be putting in the image icons instead of the condition code.

    You can upload the script and test it out by itself to get the CSS style tweaked.

    Here is the script:
    PHP Code:
    <?php
    // Minimal Current Weather Widget
    date_default_timezone_set('Europe/London');
    $woeid=21125;

    // Use PHP CURL to get XML data for defined WOEID ...
    $feed_url "http://weather.yahooapis.com/forecastrss?w=".$woeid."&u=c";
    $curl curl_init(); 
    curl_setopt($curlCURLOPT_URL,"$feed_url"); 
    curl_setopt($curlCURLOPT_RETURNTRANSFER1); 
    curl_setopt($curlCURLOPT_CONNECTTIMEOUT0); 
    $xml curl_exec($curl); 
    curl_close($curl); 
    $weather simplexml_load_string($xml); 
    if(!
    $weather) die('weather failed');
    $copyright $weather->channel->copyright;
    $item_yweather $weather->channel->item->children("http://xml.weather.yahoo.com/ns/rss/1.0");
    $flag=0;
    $flag2=0;
    foreach(
    $item_yweather as $x => $item_item) {
        foreach(
    $item_item->attributes() as $k => $attr){ 
            
    $yw_channel[$x][$k] = $attr;
                if(
    $x=="condition" && $k=="code" && $flag==0){$fc=$yw_channel[$x][$k]; $flag=1;}
                if(
    $x=="condition" && $k=="temp" && $flag2==0){$temp=$yw_channel[$x][$k]; $flag2=1;}
                
    //echo $x.":".$k."|".$attr."<br>";
        
    }
    }
    echo 
    "<div style='font-family:arial; font-size:14px; color:#aaa;'>";
    echo 
    strtoupper(date('j F Y'))." | ".$temp."&deg;C - condition code:".$fc;
    // Instead of condition code, display image
    // $image="c".$fc.".png";
    // echo "<img src='path to images/".$image."' />";
    echo "</div>";
    ?>


    .

  • Users who have thanked mlseim for this post:

    Common (10-27-2013)

  • #7
    Regular Coder Common's Avatar
    Join Date
    Jan 2009
    Location
    Glasgow, UK
    Posts
    132
    Thanks
    16
    Thanked 13 Times in 13 Posts
    Thanks again for all of that, you were a great help! You can see the widget I've come up with now over on the site: www.getoutglasgow.com

    For the moment I've just gone with the text output of current conditions, but I'm going to be working on my own icon set to go alongside!

    Thanks again.

  • #8
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,371
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    That looks great. I also really like your logo (city skyline) with the reflection. Classy.

    At first, I thought the logo was like a "sound wave file" display ... as in "Hey, we're telling you now what is happening!". Then I realized it was the city skyline and reflection.

    In my opinion, the weather icon should be where the time is now displayed. I think most people already know what time it is. Besides, it won't update time unless the page is refreshed.


    EDIT:
    Looking at this page:
    http://getoutglasgow.com/10-best-bar...w-city-centre/

    That got me thinking about a Google Map / PHP mashup I made. I use it to locate exact GPS positions for various things. In the example script below, you pan and zoom, dragging the marker around to pinpoint a location. In this case, the exact spot where those bars are located. You can write something about the location and process. A PHP script can save the GPS coordinates and marker info into a database. Perhaps you can give people the GPS coordinates or another Google Map to help them navigate. Or maybe display a little Google Map along-side each article you wrote about the various bars?

    Display it by MAP, SATELLITE, or HYBRID. There's even a street view. It's just a way to pinpoint locations visually and letting Google tell you the GPS coordinates.

    I don't have the PHP script for the whole database thing, but just a brief example of how PHP can take the information from the form and display it.

    Here is my working example. I put your city in the script as the default starting point.
    http://www.catpin.com/glasgow

    If you might be interested in the whole thing zipped, please PM me with your email address.



    .
    Last edited by mlseim; 10-27-2013 at 11:40 PM.

  • Users who have thanked mlseim for this post:

    Common (10-28-2013)

  • #9
    Regular Coder Common's Avatar
    Join Date
    Jan 2009
    Location
    Glasgow, UK
    Posts
    132
    Thanks
    16
    Thanked 13 Times in 13 Posts
    Thanks for your feedback! Yes, I'm very happy with the new logo. Just made that yesterday, and the resemblance to soundwaves struck me as well immediately after making it, however it was entirely a happy coincidence! As you say, it evokes the kind of "pulse" of the city, but also Glasgow has a fantastic music scene which we cover every week so this ties in nicely too.

    I would certainly be interested in seeing the code for your map system. Simply the idea of adding a map to that type of post is a very good idea, and that article in particular receives a great deal of search engine traffic, so definitely worth my time to improve it.

    However I wonder, is it not possible to do something like this simply within the default Google Maps API? Would I not be able to drop pins on a map and embed this, rather than using a bespoke system? Just curious, not something I've used a great deal in the past.

    Edit: Also, regarding the weather widget! I'll definitely be adding the weather icon to the same box as the time, however I do want the time to stay as I intended this box to be a kind of "link" to Glasgow for people who may no longer be in the city but still curious about what's going on. I was thinking about the fact that it needs to refresh to update, too, earlier today. Think I'll probably just use a little javascript to keep it ticking over.
    Last edited by Common; 10-28-2013 at 05:41 PM.

  • #10
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,371
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    That script I have is a location tool that you or someone will use to get the actual GPS location for a bar, concert, event, etc. You'll discover that if you just enter an address into Google, it won't place the marker exactly where YOU want it to be. The marker will be across the street, on top of an adjacent building, or just not where the door is to the establishment you wish to mark. You're working in a city that is crowded, lots of streets, and establishments within close proximity.

    That's the beauty of the Mashup I made. You use the map/satellite to move the marker to the exact location. Accuracy is within a 2 meter circle when you zoom in all the way and get the GPS location. Once you have the location, a PHP script can save that into a database.

    It's at that point where you use another script to actually display a marker on a different embedded map. You can even make your own markers. You'll use the GPS locations that YOU determined, not Google. Your markers will always be in the correct location.

    Not sure how much database stuff you wish to get into, nor your experience with that much PHP scripting. Just having GPS coordinates might allow you to use a WP plugin for maps.

    As an experiment, try this. Here is the address for the Variety Bar:
    401 Sauchiehall Street, Glasgow G2 3LG, Scotland

    Enter that address into Google and see where Google Map places the marker.

    When I did that, it placed me at the Nice-N-Sleazy bar located 1/2 block away. So the Variety Bar might not be pleased that Google Map is marking a competitor's bar?

    Using my location mashup, I would pick this GPS location for the "Variety Bar":
    55.86593248458031, -4.268268977324055

    Enter that into Google Map and it will mark the location much better.

    To me, this would be the location for "Nice-N-Sleazy":
    55.86601074820921, -4.268987809340047

    Knowing the exact GPS location will place it correctly every time. Especially establishments such as these. They are about 50 meters apart.

    So each location would have a GPS location saved and another Google Map Mashup would be used to embed a map into each entry on your site.

    There are some WP plugins to display small Google Maps using GPS:
    http://wpvortex.com/wordpress/google...for-wordpress/



    .
    Last edited by mlseim; 10-28-2013 at 11:55 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •