Support » Plugins » Weather Hack

Viewing 15 replies - 1 through 15 (of 207 total)
  • I am using phpWeather on my site.
    Their last update was Feb. 02, 2004.
    It gets information from an airport station. Does yours use the same stations? phpWeather stations seem to update every 45 minutes, it would be nice to have a more frequent update. It uses a database to cache the station information, however, I have my settings set not to use the database, because it wouldn’t update.
    I’ll have to say, your cloud icons are nicer.

    Logan, I’m pretty sure it’s not doing any caching at all. every time the page is loaded it fetches new info.
    I really would rather have the option to cache, but I don’t have time to get that working right now.
    NM, I thought it looked pretty good as well, thats why I tried to get it working for wordpress! 🙂
    I’ve never done anything with PHP before, but I have a little perl and javascript exp. so, while I’m not entirely lost, I guess I may as well be.. lol I think that the design will have to remove the alignment option in order to validate as XML.. is that correct? I’m wanting to say that you can’t have the alignment specified within the content.
    Probably be better to just drop the table entirely and just flow the info in with br’s and have it honor whatever alignment is set already in the sidebar.
    Just to be clear, I didn’t write this originally, it was written for mambo (credit for the original author is in the file, I can’t remember his name off the top of my head) I thought it looked nifty and the code looked clean, so I stripped all the mambo specific stuff out, cleaned it up a bit and posted it here.

    There’s certainly no need to keep the table structure. You could easily build it in a DIV and then create some styling with CSS. One thing about XHTML is that it is a lot fussier than HTML in that you have to tighten up some of the things you used to get a away with in plain HTML.
    Example, you have to “close” tags that once didn’t have a closing part, as in the < br /> tag. Another is that you must order your tags correctly, as in this example:
    < em > < strong > Text goes here < /em > < /strong > is bad in XHTML.
    < em > < strong > Text goes here < /strong > < /em > is semantically correct.
    All kinds of little stuff like that.

    This is really nice! I don’t have it up on my site right now, but I’ll probably be adding it to one of my pages soon. Thanks! 🙂

    ok, I cleaned it up a little more and made it respect the wordpress stylesheet.
    Tables are gone. Also seems to validate now.
    new file is available here:
    Example with all options:
    I used SPAN’s to seperate the title and the info, e.g. “Temp” and “69f”
    you can access them in your stylesheet thus:
    .weather_title { font-weight: bold; }
    #weather { text-align: center; }
    #weather ul li { text-align: center; }
    (obviously, I have this flowing in as a LI in the menu UL)

    That’s sweet! I’ve got it up and running on my site now. It was so easy! I made a couple of minor changes to the code (I moved the icon pic out of the LI tag (the little dot was driving me nuts) and put the code in a function that I can then call (so I don’t clutter my menu code. I think that about does it for the changes I made.

    TG, Glad you like it!
    this is how I am calling it in my index.php:
    <?php include(ABSPATH . ‘weather/weather.php’); ?>
    is there a better way?

    Well, what I did was to put all of the what I call “loose” code (that would be any code that wasn’t in a function already, and jsut runs when the file is included) into a function. I then used the my-hacks to include the file (which is what it’s for). Then in my menu I call the function.
    Looks something like this:
    In my-hacks.php: <?php include_once(“/weather.php”);
    In menu.php: <?php show_wp_weather(); ?>
    There’s an advantage to this method. Let’s say I wanted to show the weather for different places, I could then add a parameter to the function and pass in the station code for each place I want to display. Or, let’s say I add the ability to let the user set their location so their weather shows up. By having in the function, I can pass in a different code, and viola!
    It’s really a minor thing, and as a developer, I like to have things encapsulated like that. Especially when it gives greater flexibility to the user of the code.

    Has this weather hack been documented in the Wiki? 🙂

    That sounds pretty nifty TG..
    I had originally wanted to use the my-hacks.php and just output the $weather bit in the page, but hadn’t gotten that far. Your solution sounds nicer.
    do you want to put that up in the wiki? I tried the other day to log in, and couldn’t.
    Doesn’t taking the image out of the LI break the logical flow of the code? for screen readers and such?
    I didn’t like the bullet either, but I thought it should stay inside the UL, so I just styled it out.

    No, it doesn’t break the layout at all.
    what it ends up looking like is this:
    the UL has the title “Weather For Station XYZ” a break, and then the image. Then the UL follows, with each detail item in LI tags.

    TG – I tried your method in my-hacks.php, but that makes it display the results of weather.php after it is parsed and I can’t navigate through my wp admin page at all! Am I missing something when implementing that code?

    Ummm…. ?? I dunno…. can you make a text copy of your weather.php file so I can take a look….. wait… better yet, let me supply a link to my copy.
    Gimmie a few.

    OK, I posted my copy of weather.php right here.
    I have an hard coded hr tag in there that you might want to take out, otherwise it’s good to go.
    I dumped it (and all of the files from the original download) into a folder called wp-weather. Then in my-hacks.php, I have the line include_once(‘wp-weather/weather.php’);
    In my menu, I call the weather function like this:
    <?php show_wp_weather(); ?>
    And that’s all I did.

    Yeah, mine looks like that. Would you want to use include_once and not require_once? I should try require_once to see if that does what I want it to do, as include_once makes it display on all my admin pages.

Viewing 15 replies - 1 through 15 (of 207 total)
  • The topic ‘Weather Hack’ is closed to new replies.