WXforum.net
Web Weather => Weather Website PHP/AJAX scripting => Topic started by: Gonzo1982 on April 16, 2018, 10:28:22 AM
-
Hello,
I'm having an issue with the icons in the saratoga weather nws forecast script. If I call the script from inside my wordpress website, the images don't show, https://coffeesevereweather.com/current-forecast/. But if I call the script by going straight to it, https://coffeesevereweather.com/advforecast2.php, it works fine. Any ideas?
-
It's due to the WordPress site and the scripts aren't really designed to handle how WordPress tweaks about with the URL:filesystem path mappings.
The easiest way to get it to work in a WP page is to use an <iframe> to reference the content where you know it works (your document root).
Something like <iframe src="https://coffeesevereweather.com/advforecast2.php" width="620" height="1024" scrolling="no">
</iframe>
on your /current-forecast/ WP page. You may have to adjust the height to get it all to fit without scrollbars.
The advforecast2.php script could likely be used on your main index.php setup, but not in a sub-page due to the relative directory addressing.
Hope this helps...
-
Thanks, That gets me going for now. I'll keep messing with calling the script. Maybe I can get it working. Thanks for your scripts btw. Using the GR3 radar and now the forecast, both are very useful.
-
Keep in mind that for advforecast2.php to work correctly, the URL-path and Filesystem-path need to match. That is:
advforecast2.php
DualImage.php
./forecast/images/*
./forecast/icon-templates/*
need to have that filesystem and URL-path setup to operate properly. By 'match' I mean that
http://your.website.com/ maps to /home/somepath/httpdocs
http://your.website.com/forecast/images/skc.jpg maps to /home/somepath/httpdocs/forecast/images/skc.jpg
etc. WordPress does funny internal mapping so the URL-path and filesystem path for the real file don't always match and that breaks the script.
Oh, and don't change the internal addressing in advforecast2.php from relative filesystem addressing (./forecast/images) to URL addressing (https://...) -- it will break the script in other ways.
-
Alright, I feel like I should be able to get this fixed somehow. On your GR3 script, it's pulling the radar images from a separate folder, like /gr3/khtx_br1_0.jpg and that's loading fine in WordPress, https://coffeesevereweather.com/real-time-radar/.
-
The GRlevel3 radar script does some funny stuff (of which I'm not proud) to try and suss out the URL address of /GR3 with the filesystem address of the same. It is the only script of mine that does that, and I don't recommend trying to clone that method into advforecast2.php.
A simpler approach (if you have SSH access to your website) is to create a symlink inside the /current-forecast/ directory to where the 'real' forecast directory is like cd httpdocs/current-forecast
ln -s ../forecast forecast
ln -s ../advforecast2.php advforecast2.php
ln -s ../DualImage.php DualImage.php
Then have the page do the equivalent (in WordPress) of include("advforecast2.php");
and the page should display completely and be happy with the subdirectory placement of the WP page.
-
I was able to make the iframe work by messing with the css to change the colors to match my theme. One question though, is there a way to remove all of the dead white space to the right or center the content to the page?