Title: Weather Hack
Last modified: August 18, 2016

---

# Weather Hack

 *  [jeremiah](https://wordpress.org/support/users/jeremiah/)
 * (@jeremiah)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/)
 * I just got through cleaning up a weather module that was originally for mambo.
   
   It displays the current weather conditions for a specified station with a pretty
   icon. See it in action here: [http://www.sonicpling.net](http://www.sonicpling.net)
   With all options enabled: [http://www.sonicpling.net/weather/weather-full.php](http://www.sonicpling.net/weather/weather-full.php)
   Get the zip file here: [http://www.sonicpling.net/weather/weather.zip](http://www.sonicpling.net/weather/weather.zip)
   there’s a csv file included that list stations It doesn’t validate. and I don’t
   have time to fix it right now. I may later, but if someone wants to jump in and
   do that I’d be happy to update the zip file. Thanks, Jeremiah

Viewing 15 replies - 1 through 15 (of 207 total)

1 [2](https://wordpress.org/support/topic/weather-hack-1/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/weather-hack-1/page/3/?output_format=md)…
[12](https://wordpress.org/support/topic/weather-hack-1/page/12/?output_format=md)
[13](https://wordpress.org/support/topic/weather-hack-1/page/13/?output_format=md)
[14](https://wordpress.org/support/topic/weather-hack-1/page/14/?output_format=md)
[→](https://wordpress.org/support/topic/weather-hack-1/page/2/?output_format=md)

 *  [LoganSix](https://wordpress.org/support/users/logansix/)
 * (@logansix)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35566)
 * I am using [phpWeather](http://phpweather.sourceforge.net/) on my site. [http://www.dean-logan.com/](http://www.dean-logan.com/)
   
   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.
 *  Thread Starter [jeremiah](https://wordpress.org/support/users/jeremiah/)
 * (@jeremiah)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35587)
 * 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. –Jeremiah
 *  [NuclearMoose](https://wordpress.org/support/users/nuclearmoose/)
 * (@nuclearmoose)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35588)
 * Jeremiah,
    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.
 *  [snark_goddess](https://wordpress.org/support/users/snark_goddess/)
 * (@snark_goddess)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35601)
 * 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! 🙂
 *  Thread Starter [jeremiah](https://wordpress.org/support/users/jeremiah/)
 * (@jeremiah)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35747)
 * 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: [http://www.sonicpling.net/weather/weather-new.zip](http://www.sonicpling.net/weather/weather-new.zip)
   Example: [http://www.sonicpling.net](http://www.sonicpling.net) Example with 
   all options: [http://www.sonicpling.net/weather/weather-full.php](http://www.sonicpling.net/weather/weather-full.php)
   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) Comments?
 *  [TechGnome](https://wordpress.org/support/users/techgnome/)
 * (@techgnome)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35750)
 * 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
 *  Thread Starter [jeremiah](https://wordpress.org/support/users/jeremiah/)
 * (@jeremiah)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35755)
 * 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? –Jeremiah
 *  [TechGnome](https://wordpress.org/support/users/techgnome/)
 * (@techgnome)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35764)
 * 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. TG
 *  [NuclearMoose](https://wordpress.org/support/users/nuclearmoose/)
 * (@nuclearmoose)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35772)
 * Has this weather hack been documented in the Wiki? 🙂
 *  Thread Starter [jeremiah](https://wordpress.org/support/users/jeremiah/)
 * (@jeremiah)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35786)
 * 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. 
   Thanks, Jeremiah
 *  [TechGnome](https://wordpress.org/support/users/techgnome/)
 * (@techgnome)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35804)
 * 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
 *  Anonymous
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35880)
 * 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?
 *  [TechGnome](https://wordpress.org/support/users/techgnome/)
 * (@techgnome)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35893)
 * 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.
   TG
 *  [TechGnome](https://wordpress.org/support/users/techgnome/)
 * (@techgnome)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35894)
 * OK, I posted my copy of weather.php [right here](http://techgnome.anderson-website.net/download/weather.txt).
   
   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. TG
 *  [Aubrey (@starshaped)](https://wordpress.org/support/users/heraubreyness/)
 * (@heraubreyness)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/weather-hack-1/#post-35924)
 * 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)

1 [2](https://wordpress.org/support/topic/weather-hack-1/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/weather-hack-1/page/3/?output_format=md)…
[12](https://wordpress.org/support/topic/weather-hack-1/page/12/?output_format=md)
[13](https://wordpress.org/support/topic/weather-hack-1/page/13/?output_format=md)
[14](https://wordpress.org/support/topic/weather-hack-1/page/14/?output_format=md)
[→](https://wordpress.org/support/topic/weather-hack-1/page/2/?output_format=md)

The topic ‘Weather Hack’ is closed to new replies.

 * 207 replies
 * 45 participants
 * Last reply from: [meowminx](https://wordpress.org/support/users/meowminx/)
 * Last activity: [19 years, 6 months ago](https://wordpress.org/support/topic/weather-hack-1/page/14/#post-36754)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
