Web Weather > Weather Website PHP/AJAX scripting
Active Weather Alert display
neondesert:
--- Quote from: "Chris from capeweather" ---
Yes, very cool. I sure would like to know how he got his 'Active weather alert' to automatically display with a link. Didn't mean to get off track but thought that would be a cool addition. If anybody knows could they post in the script forum? :)
--- End quote ---
Thanks for the compliment Chris! :D
Here is how I implemented this feature.
First, create a php file with the following code:
--- Code: ---<?php
// Check the current advisory text file size and display an alert gif and text if an advisory is issued
$size = filesize("rss-advisory-NVZ020.txt");
if($size > 1160) //1160 is the "approx" min size of rss-advisory-ZONE.txt
($warn = "<img src='anim-led-red.gif'>") && ($warntext = " Active Weather Alert Click For Details ");
?>
--- End code ---
As you can see, I am using Ken's advisory script(Thanks Ken! :wink: ) , but you may use a different source file for warnings/advisories.
Next, use this include on the pages you want to have an alert link:
--- Code: ---<?php include "alertGif.php"; ?> // use the name of your php file
--- End code ---
Finally, place this code at the location on the page you would like the display to appear:
--- Code: ---<?=$warn;?><a href="Path to your advisory page" target="_self"><?=$warntext;?></a><?=$warn;?>
--- End code ---
There are probably more elegant ways to do this, but hey it works!
I'd like to thank Matt at http://www.weatherbus.com for his help, as he uses a similar display on his site. :)
WeatherBeacon:
Thanks for the script, Larry!
Okay, I'm green: how do I obtain the file:
rss-advisory-NVZ020.txt
on my server? I know my zone number; I just don't know how I obtain that file.
Thanks!
Regards,
Kevin...
saratogaWX:
Kevin,
I think Larry is using the rss-advisory-test-c.php (Caching RSS advisory script) from http://saratoga-weather.org/scripts-rss.php#NOAARSS
The rss-advisory-ZONE.txt file is the cache file from the script.
Larry, you and Matt are very clever in the use of the 'appearing warning'.. I'll have to look at that for my site too. Thanks!
Best regards,
Ken
WeatherBeacon:
--- Quote from: "saratogaWX" ---Kevin,
I think Larry is using the rss-advisory-test-c.php (Caching RSS advisory script) from http://saratoga-weather.org/scripts-rss.php#NOAARSS
The rss-advisory-ZONE.txt file is the cache file from the script.
Best regards,
Ken
--- End quote ---
Great! I'll take a look at that.
As always --- thanks, Ken!
Regards,
Kevin...
WeatherHost:
I've looked at a few of these other scripts, but I still like the one from CarterLake. It hasn't failed me yet.
Navigation
[0] Message Index
[#] Next page
Go to full version