Author Topic: Saratoga template setup  (Read 4412 times)

0 Members and 1 Guest are viewing this topic.

Offline adrianhudson

  • Member
  • *
  • Posts: 22
Saratoga template setup
« on: July 11, 2011, 03:04:02 PM »
Hi,
I am setting the Saratoga templates up. I seem to be having problems with displaying images. The Almanac/Station Graphs page refuses to display the images.

Example:
http://www.willandweather.org.uk/wxgraphs.php

I am using WD. Here is an extract from my settings-weather.php

$SITE['graphImageDir']  = 'D:/wdisplay/webfiles/';  // directory location for graph images with trailing /
# wxhistory.php settings
$SITE['HistoryStartYear'] = '2005';  // start year for station operation
$SITE['HistoryFilesDir']  = 'D:/wdisplay/webfiles/';    // directory location for the [month][year].htm history files
$SITE['HistoryGraphsDir'] = 'D:/wdisplay/webfiles/';    // directory location for the YYYYMMDD.gif graphic daily report files

As you can see there are direct paths to the Weather Display webfiles folders where the required files live (have checked they are there!)
I run my own web server on the same machine as WD - hence direct paths

The same thing happens on the Almanac/Station Monthly Reports pages where there is a link "Click here to toggle the 24 Hour Graph of this day" which also does not work.

http://www.willandweather.org.uk/wxhistory.php

Does anyone have any idea why I am getting blank pages please?


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga template setup
« Reply #1 on: July 11, 2011, 06:21:09 PM »
Ahh, but the direct paths aren't directly accessable from the webserver .. they need to be relative file paths from the document root of the website in order for the script to work correctly.  Your current settings produce HTML like
Quote
   <h1>Last 24 Hours</h1>
      <img src="D:/wdisplay/webfiles/curr24hourgraph.gif" alt="Last 24 hours" width="469" height="555" />
   <br /><br />
   <h1>Last 72 Hours</h1>
      <img src="D:/wdisplay/webfiles/curr72hourgraph.gif" alt="Last 72 hours" width="469" height="555" />

   <br /><br />
   <h1>Month to Date</h1>
      <img src="D:/wdisplay/webfiles/monthtodate.gif" alt="Month to Date" width="469" height="555" />
and the graphs on the wxhistory page have
Quote
<p onclick="toggleDisplay('img_' + 20110701);">
Click here to toggle the 24 Hour Graph of this day</p>
<img src="D:/wdisplay/webfiles/20110701.gif" id="img_20110701" style="display: none" onclick="toggleDisplay('img_' + 20110701);" alt="24 Hour Graph for Day 01" title="24 Hour Graph for Day 01" />


It's the D:/wdisplay/webfiles/ that makes it an invalid URI.  So, something like
Code: [Select]
$SITE['graphImageDir']  = './';  // directory location for graph images with trailing /
# wxhistory.php settings
$SITE['HistoryStartYear'] = '2005';  // start year for station operation
$SITE['HistoryFilesDir']  = './';    // directory location for the [month][year].htm history files
$SITE['HistoryGraphsDir'] = './';    // directory location for the YYYYMMDD.gif graphic daily report files

is what is needed in the settings.  Then make sure the files are in the primary document root for the website.

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 adrianhudson

  • Member
  • *
  • Posts: 22
Re: Saratoga template setup
« Reply #2 on: July 11, 2011, 07:04:00 PM »
Thanks for the reply Ken.

The files are actually in a virtual folder "wdwebfiles" which is in the primary document root for the website. The virtual folder points to the (real) WD "webfiles" folder so you can display any of the documents in there if you know its name. e.g. click this link

http://www.willandweather.org.uk/wdwebfiles/curr24hourgraph.gif

I have tried
$SITE['graphImageDir']  = './wdwebfiles/'; 

I have tried
$SITE['graphImageDir']  = 'X:/wdisplay/webfiles/';   (remember, everything is on the same machine - website and weather display)

I have tried
$SITE['graphImageDir']  = '../../wdisplay/webfiles/';  (which also correctly targets the folder via the machine's file system)

and I have tried
$SITE['graphImageDir']  = 'http://www.willandweather.org.uk/wdwebfiles/';  (which targets the files directly see link above)

Interestingly, in the case of the second and third examples above, the page is displayed in the browser with no errors. If I introduce a typo, say, 'X:\wdisplay\webfddddddddiles\' the script complains it can't find the files. I have left it configured as the first example now so you can see. If I replace the config with either the second or third examples above then the error message goes away but nothing is displayed. Its as though the script is finding the files but the browser (or something else) doesn't know how to display .gif files.

Thanks for your help on this, I am very grateful
Adrian

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga template setup
« Reply #3 on: July 11, 2011, 07:30:02 PM »
Hi Adrian,

The issue is with the use of virtual folders I think...

The PHP script knows that './' is the current directory.  Generally, webservers tend to have a linear relationship with published URI directories and the filesystem directories so that:

http://some.website/script.php   resides in the document root of the website and files in the same directory are in './'
http://some.website/subdir/thing.gif uses the URI of /subdir/thing.gif and should be found in ./subdir/thing.gif

Using a virtual directory may make this a non-linear structure that PHP is unable to navigate.

You do need to exclude any mention of the absolute filesystem path (like X:/wdisplay/webfiles/ ) as it is completely unusable on the web (Invalid URI addressing).  Also eschew the full URL addressing (http://...) as it can't be used natively by PHP (which only understands file paths in the filesystem of the webserver).

I'm afraid you'll need to drop the virtual mapping for use with the templates unless you map the entire wdwebfiles to your document root, or move your template set into the same directory.

You will need to use './' or './directory/' as the addressing, but the ./directory/ has to be just below ./ in the filesystem in order for it to work.

You can get WD to upload the files to the same directory as the template files, and that would work also.. but not the virtual directory mapping, I fear.

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 adrianhudson

  • Member
  • *
  • Posts: 22
Re: Saratoga template setup
« Reply #4 on: July 12, 2011, 06:34:59 AM »
Ken,

Thank you.

I made a junction "webfiles" in the web root folder which points to Weather Display webfiles folder "X:\wdisplay\webfiles". I then set $SITE['graphImageDir']  = './webfiles/'; and all workinng now. The scripts as you say, don't like Apache webserver virtual folders but they are quite happy with the junction.

All working fine now. Much obliged for your help!

 

anything