Author Topic: $useTopWarning event box color  (Read 561 times)

0 Members and 1 Guest are viewing this topic.

Offline NorCal_Dan

  • Member
  • *
  • Posts: 17
    • Traveling RV Wx
$useTopWarning event box color
« on: December 15, 2018, 06:30:32 PM »
Why is my NWS event box color not changing to match the severity of the event?  When I have it set to show all events the box remains yellow all the time.  When set to display only the most severe event it does change color, ie. red for warnings, yellow for watches.

I've researched this extensively and it seems this is how the code, as documented, is suppose to work.  But I know of one station near me where the box does change color AND displays multiple events.

See attachments...

Box changes color -- http://www.beachhouseweather.com/
Box doesn't change color -- http://travelingrvwx.com/

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: $useTopWarning event box color
« Reply #1 on: December 15, 2018, 06:57:56 PM »
Your site seems to be using atom-advisory/atom-top-warning for display on the home page.

Their site is using the nws-alerts script set to display that box.

You can switch your site to use the nws-alerts version instead by changing your index.php from
Code: [Select]
<?php // insert desired warning box at top of page
  
if ($useTopWarning) {
 if (phpversion() < 5.0) { 
       include_once(
"rss-top-warning.php");
 } else {
   include_once("atom-top-warning.php");
 }
  } else {
   print 
"      <div class=\"advisoryBox\">\n";
   
$_REQUEST['inc'] = 'y';
   
$_REQUEST['summary'] = 'Y';
   if (
phpversion() < 5.0) {
     include_once(
"rss-advisory.php");
   } else { 
     include_once(
"atom-advisory.php");
   }
   print 
"      </div>\n";
  }
?>
<div class="column-dark">
to
Code: [Select]
<?php // insert desired warning box at top of page

  
if(isset($SITE['NWSalertsCodes']) and count($SITE['NWSalertsCodes']) > 0) {
// Add nws-alerts alert box cache file
include_once("nws-alerts-config.php");
include($cacheFileDir.$aboxFileName);
// Insert nws-alerts alert box
echo $alertBox;
?>

<script type="text/javascript" src="nws-alertmap.js"></script>
<?php
  
  } else { 
// use atom scripts of choice
if ($useTopWarning) {
  include_once("atom-top-warning.php");
} else {
 print "      <div class=\"advisoryBox\">\n";
 $_REQUEST['inc'] = 'y';
 $_REQUEST['summary'] = 'Y';
 include_once("atom-advisory.php");
 print "      </div>\n";
}
  }
?>

<div class="column-dark">
When nws-alerts was integrated with the template, the older atom-advisory and atom-top-warning scripts were deprecated as the nws-alerts script set provided much more functionality.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline yamiacaveman

  • Forecaster
  • *****
  • Posts: 439
    • Penn Lake Weather
Re: $useTopWarning event box color
« Reply #2 on: December 27, 2018, 02:55:46 PM »
Hi Ken,
 I think my alert is working properly, but after reading this post I went back to check the code I had in my index.php

2 things I noticed that are different: I have this at the top of my code,  <div class="column-dark"> as in
//
$useTopWarning = false;  // set to true to use only the rss-top-warning script
//                         set to false to use the rss-advisory script instead
?>

<div id="main-copy">
   
<div class="column-dark">
   
<?php // insert desired warning box at top of page

And I do not have this line of code:   <script type="text/javascript" src="nws-alertmap.js"></script>


I do have an announce script added in there -- I guess what I'm asking - should I add the above line in there??? below is what I have.
top-warning script
//                         set to false to use the rss-advisory script instead
?>

<div id="main-copy">
   
<div class="column-dark">
   
<?php // insert desired warning box at top of page
if(isset($SITE['NWSalertsCodes']) and count($SITE['NWSalertsCodes']) > 0) {
 // Add nws-alerts alert box cache file
 include_once("nws-alerts-config.php");
 include($cacheFileDir.$aboxFileName);
 // Insert nws-alerts alert box
 echo $alertBox;
} else { // use atom scripts of choice
 if ($useTopWarning) {
  include_once("atom-top-warning.php");
} else {
 print " <div class=\"advisoryBox\">\n";
 $_REQUEST['inc'] = 'y';
 $_REQUEST['summary'] = 'Y';
 include_once("atom-advisory.php");
 print " </div>\n";
 }
}
?>
<?php
 include_once("./specanounconfig.php"); // include the settings
 include_once($cfolder.$cfile);         // include the cache file
 if(date("U") <= $spandata[1]) {echo $spanmessage;}
?>
<div class="column-dark">
<div align="center">
<!--  <br/>