Author Topic: NWS website changed .. advforecast2.php V3.03 02-Jul-2012 now available  (Read 24487 times)

0 Members and 1 Guest are viewing this topic.

Offline Cutty Sark Sailor

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 3394
    • Frankfort Weather - TwinHollies WeatherCenter
Re: NWS website changed .. advforecast2.php V3.03 02-Jul-2012 now available
« Reply #125 on: July 07, 2012, 04:48:56 PM »
Anybody know how to change the spacing between the icons? I'd like to make them just a touch wider so they are not crunched together. Tried messing around with the code but no luck.
Font size is part of the issue:
Try Below to get something like the image:

Down about line 832 in advforecast2.php:
Code: [Select]
<td align="center">&nbsp;
           <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr valign ="top" align="center">
        <?php
          
for ($i=0;$i<count($forecasticons);$i++) {
// fixes tstorms in main forecast page
    
$forecasticons[$i] = preg_replace('|Thunderstorms|','T-Storms',$forecasticons[$i]);

            print 
"<td style=\"width: 11%;\"><span style=\"font-size: 9px; color:#101070; line-height:1.3em;\">$forecasticons[$i]</span></td>\n";
          }
        
?>

          </tr>
          <tr valign ="top" align="center">
          <?php
          
for ($i=0;$i<count($forecasticons);$i++) {
            print 
"<td style=\"width: 11%; font-size:11px; font-weight:600;\">$forecasttemp[$i]</td>\n";
          }
          
?>

          </tr>
        </table>
     </td>
   </tr>
</table>
 


Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS website changed .. advforecast2.php V3.03 02-Jul-2012 now available
« Reply #126 on: July 07, 2012, 10:16:07 PM »
While it is perfectly ok to modify any of my scripts for your own use, I'd like to suggest a couple of ideas to help minimize your efforts to keep your template-based site working with new releases of the scripts as they become available.
I do tend to treat all the support scripts in the templates as 'just replaceable' without mods on your site since the major configuration is done in Settings.php for things like advforecast2.php.

So.. to simplify your future maintenance, consider a slight mod to wxforecast.php to replace
Code: [Select]
<div id="main-copy">
         <?php 
 $doIncludeNWS true// handle advforecast2.php include
 $doIncludeWU  true// handle WU-forecast include also
 $doInclude    = true// handle ec-forecast and WXSIM include also
 $doPrint    = true//  ec-forecast.php setting
 include_once($SITE['fcstscript']); ?>


with
Code: [Select]
<div id="main-copy">
         <?php 
 $doIncludeNWS true// handle advforecast2.php include
 $doIncludeWU  true// handle WU-forecast include also
 $doInclude    = true// handle ec-forecast and WXSIM include also
 $doPrint    = false//  ec-forecast.php setting
                 
$doPrintNWS false// suppress printing of advforecast2.php
 include_once($SITE['fcstscript']); ?>


which will give all $forecast... variables filled in for you to print yourself.

In the bottom of advforecast2.php, the code to print can be copied to the wxforecast.php page and you can play around with the layout all you like AND not have to refit your mods when a newer advforecast2.php gets released (as it will when the NWS website changes...).

Here's the 'printing-part' of the advforecast2.php script you can include in your page
Code: [Select]
<?php
}
print 
$Status;
// if the forecast text is blank, prompt the visitor to force an update

if (strlen($forecasttext[0])<and $PrintMode ) {
  if(!isset(
$PHP_SELF)) { $PHP_SELF $_SERVER['PHP_SELF']; }
  echo 
'<br/><br/>Forecast blank? <a href="' $PHP_SELF '?force=1">Force Update</a><br/><br/>';

}
?>

  <table width="640" style="border: none;">
    <tr align="center">
      <td><b>National Weather Service Forecast for: </b><span style="color: green;">
           <?php echo $forecastcity?></span><br />
        Issued by: <?php echo $forecastoffice?>
      </td>
    </tr>
    <tr>
      <td align="center">Updated: <?php echo $forecastupdated?>
          </td><!--end forecastupdated-->
    </tr>
    <?php echo $ddMenu ?>
    <tr>
  <td align="center" style="font-size: 18px; margin: 0px auto;"><b><?php echo $NOAAlocation?></b></td>
    </tr>
    <tr>
      <td align="center">&nbsp;
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr valign ="top" align="center">
        <?php
          
for ($i=0;$i<count($forecasticons);$i++) {
            print 
"<td style=\"width: 11%;\"><span style=\"font-size: 8pt;\">$forecasticons[$i]</span></td>\n";
          }
        
?>

          </tr>
          <tr valign ="top" align="center">
          <?php
          
for ($i=0;$i<count($forecasticons);$i++) {
            print 
"<td style=\"width: 11%;\">$forecasttemp[$i]</td>\n";
          }
          
?>

          </tr>
        </table>
     </td>
   </tr>
</table>
  <p><?php 
  
if($forecastwarnings <> '') {
  print $forecastwarnings;
  }
?>
&nbsp;</p>

<table style="border: 0" width="640">
        <?php
          
for ($i=0;$i<count($forecasttitles);$i++) {
        print 
"<tr valign =\"top\" align=\"left\">\n";
            print 
"<td style=\"width: 20%;\"><b>$forecasttitles[$i]</b><br />&nbsp;<br /></td>\n";
            print 
"<td style=\"width: 80%;\">$forecasttext[$i]</td>\n";
                print 
"</tr>\n";
          }
        
?>

   </table>

<p>&nbsp;</p>
<p>Forecast from <a href="<?php if($usingFile) {
 echo 
htmlspecialchars($backupfileName);
 } else {
  echo 
htmlspecialchars($fileName);
 } 
?>
">NOAA-NWS</a>
for <?php echo $forecastcity?>. <?php echo $usingFile?>
<?php if($iconType <> '.jpg') {
print "<br/>Animated forecast icons courtesy of <a href=\"http://www.meteotreviglio.com/\">www.meteotreviglio.com</a>.";

?>

</p>

Hope this helps...

Best regards,
Ken

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 Farmtalk

  • Fitzweather
  • Forecaster
  • *****
  • Posts: 4745
    • WV Waterfalls
Re: NWS website changed .. advforecast2.php V3.03 02-Jul-2012 now available
« Reply #127 on: October 20, 2012, 10:16:13 AM »
I have been trying to get the dropdown menu to appear on my script but can't seem to get it right. Here is my code, does anyone see anything wrong with it???

Thanks! 8-)

Quote
// ZONE|Location|point-forecast-URL  (separated by | characters
"WVZ027|Bickmore, WV |http://forecast.weather.gov/MapClick.php?lat=38.38356&lon=-81.11049700000001&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Clay, WV |http://forecast.weather.gov/MapClick.php?lat=38.46280&lon=-81.0802&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Dille, WV |http://forecast.weather.gov/MapClick.php?lat=38.46621&lon=-80.85732289999998&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Indore, WV|http://forecast.weather.gov/MapClick.php?lat=38.36090&lon=-81.15931699999999&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Ivydale, WV |http://forecast.weather.gov/MapClick.php?lat=38.53556&lon=-81.03499999999997&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Lizemores, WV |http://forecast.weather.gov/MapClick.php?lat=38.33399&lon=-81.1751099&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Maysel, WV |http://forecast.weather.gov/MapClick.php?lat=38.48593&lon=-81.1126102&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Nebo, WV|http://forecast.weather.gov/MapClick.php?lat=38.63454&lon=-81.04260909999999&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Procious, WV |http://forecast.weather.gov/MapClick.php?lat=38.47040&lon=-81.2208&unit=0&lg=english&FcstType=text&TextType=2",
);
Joe Fitzwater
Chief Meteorologist for WVNS-TV 59 in Beckley, WV

Work Page on Facebook -> www.facebook.com/meteojoe
Work Page on Twitter -> https://twitter.com/meteojoe
Waterfalls -> www.wvfalls.com

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS website changed .. advforecast2.php V3.03 02-Jul-2012 now available
« Reply #128 on: October 20, 2012, 11:34:53 AM »
It would help to have the URL of your website that is showing the issue :)

If you are doing that change in the advforecast2.php script itself, the be aware that the code
Code: [Select]
// V3.00 -- this following array can be used for multiple forecasts in standalone mode
//  for template use, add a $SITE['NWSforecasts'] entry in Settings.php to have these entries.
//  to activate the definitions below, replace the /* with //* to uncomment the array definition
/*
$NWSforecasts = array(
 // the entries below are for testing use.. replace them with your own entries if using the script
 // outside the AJAX/PHP templates.
// ZONE|Location|point-forecast-URL  (separated by | characters
"WVZ027|Bickmore, WV |http://forecast.weather.gov/MapClick.php?lat=38.38356&lon=-81.11049700000001&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Clay, WV |http://forecast.weather.gov/MapClick.php?lat=38.46280&lon=-81.0802&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Dille, WV |http://forecast.weather.gov/MapClick.php?lat=38.46621&lon=-80.85732289999998&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Indore, WV|http://forecast.weather.gov/MapClick.php?lat=38.36090&lon=-81.15931699999999&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Ivydale, WV |http://forecast.weather.gov/MapClick.php?lat=38.53556&lon=-81.03499999999997&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Lizemores, WV |http://forecast.weather.gov/MapClick.php?lat=38.33399&lon=-81.1751099&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Maysel, WV |http://forecast.weather.gov/MapClick.php?lat=38.48593&lon=-81.1126102&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Nebo, WV|http://forecast.weather.gov/MapClick.php?lat=38.63454&lon=-81.04260909999999&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Procious, WV |http://forecast.weather.gov/MapClick.php?lat=38.47040&lon=-81.2208&unit=0&lg=english&FcstType=text&TextType=2",
);
//*/
is contained in a multi-line PHP comment starting with the /* line and terminated by the //*/ line.

Change the line /* to //* and the multi-line PHP comment will not be recognized, so the code below it will be processed.

Best regards,
Ken
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 Farmtalk

  • Fitzweather
  • Forecaster
  • *****
  • Posts: 4745
    • WV Waterfalls
Re: NWS website changed .. advforecast2.php V3.03 02-Jul-2012 now available
« Reply #129 on: October 20, 2012, 12:02:01 PM »
Sorry Ken,

www.fitzweather.com/advforecast2.php

It works fine other than the dropdown menu dosen't show
Joe Fitzwater
Chief Meteorologist for WVNS-TV 59 in Beckley, WV

Work Page on Facebook -> www.facebook.com/meteojoe
Work Page on Twitter -> https://twitter.com/meteojoe
Waterfalls -> www.wvfalls.com

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS website changed .. advforecast2.php V3.03 02-Jul-2012 now available
« Reply #130 on: October 20, 2012, 12:35:40 PM »
You just have to disable the multiline comment surrounding the code by changing
Code: [Select]
/*
$NWSforecasts = array(
to
Code: [Select]
//*
$NWSforecasts = array(

Then the dropdown list will display.

Best regards,
Ken
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 Farmtalk

  • Fitzweather
  • Forecaster
  • *****
  • Posts: 4745
    • WV Waterfalls
Re: NWS website changed .. advforecast2.php V3.03 02-Jul-2012 now available
« Reply #131 on: October 20, 2012, 12:38:37 PM »
Thank you Ken!! :grin: That fixed it right up!!!

Can't thank you enough! 8-)
Joe Fitzwater
Chief Meteorologist for WVNS-TV 59 in Beckley, WV

Work Page on Facebook -> www.facebook.com/meteojoe
Work Page on Twitter -> https://twitter.com/meteojoe
Waterfalls -> www.wvfalls.com

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS website changed .. advforecast2.php V3.03 02-Jul-2012 now available
« Reply #132 on: October 20, 2012, 12:46:41 PM »
You're welcome :)

Make sure that the FIRST entry in the array is the one for your default forecast .. it will be used instead of what you might have put in the
Code: [Select]
$NOAAZone = 'WVZ027';  // change this line to your NOAA warning zone.
// set $fileName to the URL for the point-printable forecast for your area
 $fileName = "http://forecast.weather.gov/MapClick.php?lat=38.46280&lon=-81.0802&unit=0&lg=english&FcstType=text&TextType=2";

So I'd suggest you change
Code: [Select]
"WVC087|Amma|http://forecast.weather.gov/MapClick.php?lat=38.56701&lon=-81.268509&unit=0&lg=english&FcstType=text&TextType=2",
"WVC097|Buckhannon|http://forecast.weather.gov/MapClick.php?lat=38.99399&lon=-80.23202759999998&unit=0&lg=english&FcstType=text&TextType=2",
"WVC039|Charleston|http://forecast.weather.gov/MapClick.php?lat=38.34982&lon=-81.6326234&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Clay|http://forecast.weather.gov/MapClick.php?lat=38.46280&lon=-81.0802&unit=0&lg=english&FcstType=text&TextType=2",
"WVC039|Clendenin|http://forecast.weather.gov/MapClick.php?lat=38.48871&lon=-81.34817450000003&unit=0&lg=english&FcstType=text&TextType=2",

to
Code: [Select]
"WVZ027|Clay|http://forecast.weather.gov/MapClick.php?lat=38.46280&lon=-81.0802&unit=0&lg=english&FcstType=text&TextType=2",
"WVC087|Amma|http://forecast.weather.gov/MapClick.php?lat=38.56701&lon=-81.268509&unit=0&lg=english&FcstType=text&TextType=2",
"WVC097|Buckhannon|http://forecast.weather.gov/MapClick.php?lat=38.99399&lon=-80.23202759999998&unit=0&lg=english&FcstType=text&TextType=2",
"WVC039|Charleston|http://forecast.weather.gov/MapClick.php?lat=38.34982&lon=-81.6326234&unit=0&lg=english&FcstType=text&TextType=2",
"WVZ027|Clay|http://forecast.weather.gov/MapClick.php?lat=38.46280&lon=-81.0802&unit=0&lg=english&FcstType=text&TextType=2",
"WVC039|Clendenin|http://forecast.weather.gov/MapClick.php?lat=38.48871&lon=-81.34817450000003&unit=0&lg=english&FcstType=text&TextType=2",
to have your Clay, WV appear as the default forecast displayed.

Also, don't use the WVC... codes .. they have no backup Zone forecast associated with them.  Only use the WVZ... codes otherwise if the point-printable forecast is not available, the Zone forecast fallback will not be available either.
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 Farmtalk

  • Fitzweather
  • Forecaster
  • *****
  • Posts: 4745
    • WV Waterfalls
Re: NWS website changed .. advforecast2.php V3.03 02-Jul-2012 now available
« Reply #133 on: October 20, 2012, 12:52:00 PM »
Thanks again! I will change those!!!  :-) :-) Really appreciate it!
Joe Fitzwater
Chief Meteorologist for WVNS-TV 59 in Beckley, WV

Work Page on Facebook -> www.facebook.com/meteojoe
Work Page on Twitter -> https://twitter.com/meteojoe
Waterfalls -> www.wvfalls.com