Author Topic: Removal / No display of forecast icaons in advforecast.php script  (Read 529 times)

0 Members and 1 Guest are viewing this topic.

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Good day All!

Is there a way to turn off the displaying of the forecast icons that the advforecast.php script produces? I just want the day, short text of forecast and the hi/low to display with NO icon.

Thanks!

Jim

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Removal / No display of forecast icaons in advforecast.php script
« Reply #1 on: February 14, 2017, 03:49:22 PM »
Rather than changing the advforcast2.php script, you can pick/choose what to display by 'silently' invoking the script and printing the variables it provides directly.

Silent invocation:
Code: [Select]
<?php
$doPrintNWS 
false;
include_once(
"advforecast2.php"); ?>

then elsewhere on the page (where you'd like to see the data) use
Code: [Select]
<?php
$i
=0// select the current icon 
print $forecasttitles[$i]."<br/>\n"// print the day name
print $forecastcond[$i]."<br/>\n"// print the short condition description
print $forecasttemp[$i]."<br/>\n"// print the formatted Hi/Lo temperature
print $forecasttext[$i]."<br/>\n";  // print the long forecast text
?>
That way, you can easily replace the advforecast2.php script when updates are available and not have to worry about refitting your mods.

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 SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Re: Removal / No display of forecast icaons in advforecast.php script
« Reply #2 on: February 14, 2017, 03:53:08 PM »
Awesome! Thanks Ken (again  =D&gt;)

Jim

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Re: Removal / No display of forecast icaons in advforecast.php script
« Reply #3 on: February 14, 2017, 03:57:23 PM »
Ruh roh, I don not see any variable called $forecastcond in my advforecast2.php script.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Removal / No display of forecast icaons in advforecast.php script
« Reply #4 on: February 14, 2017, 05:10:15 PM »
Oops.. that's correct, the current V4 advforecast2.php doesn't have a $forecastcond variable.. sorry.  The V5 of the script does (to support the March release of the new forecast.weather.gov website).

An alternative approach would be the prune out the actual <img ... /> tag from $forecasticons[$i] and display that.. it would have the day name, condition in it (with a set of <br/> tags).  Something like
Code: [Select]
<?php
$i 
0;
$cond preg_replace('|<img [^>]+>|i','',$forecasticons[$i]);
$cond preg_replace('|<br/>|i',' ',$cond);
?>

Then $cond would look like

'Thursday   Heavy Rain then Chance Rain '

Sorry for the confusion, I was looking at (and working on) the replacement advforecast2.php script which does have a $forecastcond variable added.
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

 

anything