Newton Ferrers and Noss Mayo weather
Newton Ferrers and Noss Mayo
Home : Weather : Tides : About : Contact
 


.
 Weather Tech
 
BBC Video Forecast
Spotlight News/Weather
Met Office Local Forecast
Met Office Shipping Forecast
 

Weather Tech

This tech. section is for users of WD (WeatherDisplay), weather web site developers & webmasters. Click here for our weather section!

 

Tides Processor (PHP)

Updated 16 Dec 2008

If you are generating and uploading tides with Weather Display and WXTide, you will know that the file it creates can be difficult to fit into your web pages, doesn't look that great, and isn't very flexible at all! Well the good news is that you don't have to put up with that any more. This easy to use script will enable you to put tide info any where on your site, lay it out how ever you like, show tides for individual days, show moon phase icons with your tides and more.

Tides Processor also has a separate function for displaying sun and moon rise & set times if you have that enabled in xtides. The sun and moon data can be displayed independently of the tides, or can be shown with the tides.

Example of Tides Processor In Action
You can display tides how ever you like. Here I have put them in table cells.

Tides are always displayed starting from the current day. It will never show out of date tides from previous days. So if your WD tide file misses a few uploads (as mine does from time to time), it won't be a problem.
Adjusted for The River Yealm Entrance & BST
 
 
Or let's just show tomorrow's tides!


Installation
1. Download the zip file and unpack it.
2. Open the tides_processor.php file and change the server path variable to the path of your tideprediction.html file (the file that WD uploads).
3. Change the URL path to where you have or are going to upload the moon icons directory.
4. Check the other settings, and translations as required.
5. Upload the file and icons directory to your site.
6. There are now template files included. You can copy the code in the template file and past it into your web page, or include it through a php include for an instant tide table layout!

Usage
Easy
1a. The quickest and easiest way to put tide tables into your page, is to copy the code in the template file you wish to use, and past it into your php page. Open the template file in your editor for more info.

Advanced
1b. On any page where you want to show tides, you need to put the following in the page, above where your tides are going to be displayed. It's normally best to put it right at the top, before any html.

<?php
require_once("/home/user/public_html/path/to/tides_processor.php");
?>

(Change the above to your server path to the script!)

2. Where ever you want to display tides for a particular day, you simply put the following in your page.

<? tides(); ?>
The above code will display the tides for the current day. So will the following;
<? tides(0); ?>
To display tides for another day, simply replace the "0" for a "1" (to show tides for tomorrow), "2" (to show tides for the next day) and so on. For example;
<? tides(1); ?>
will show the tides for tomorrow...
<? tides(10); ?>
will show the tides for the tenth day from today.
Displaying sun & moon rise/set times is done in a very similar way, but with a slightly different code.
<? sunmoon(10); ?>

will show the sun and moon rise/fall times for the tenth day from today.

If you want to show sun and moon data with out the date, for example, if you are showing it with your tide times, you don't want to show two dates. So you can turn the date off by adding ",nodate" to the code tag like this;
<? sunmoon(10,nodate); ?>
will show the sun and moon rise/fall times for the tenth day from today with out the date.

 

You can go up to about 20 or so. If there is no tide data for that number of days ahead, it will simply show nothing.

Tides and sun & moon rise/set are completely separate, so they can be displayed on separate pages if you wish, but can also be shown on the same page, or in the same table cell.

Additional Settings
If your tide file contains the year in the date e.g. Saturday 2008-10-11, you must set the $yearDate variable to "yes". This script only works with the standard date formats that WD/xtides produces which are "Saturday 10-11" or "Saturday 2008-10-11".

If your tide file contains rising & falling times as well as high and low times, you can convert the output to not display rising & falling times by setting the $convertRF variable to "yes".

You can translate the output to another language by changing the tide words, day names and month names in the translations section of the script. Just replace the default words with those of your preferred language, making sure not to inadvertently change the syntax.

You can turn off the moon phase icons if you want to. Some users have reported that the moon phases in wxtides are inaccurate for their location. This can be done independently for both tides and for sun and moon rise/set.

Extra Features
In the rare event that someone visits your tides page at the same moment that WD is uploading the tide file, rather than show missing file errors, and blank tides, the script will display a message saying that the tide data is being updates, and ask the visitor to reload the page.

Dates are converted to a more presentable format.

You can actually use this script even if you don't have WD uploading a tide file to your site! The script can be used to get the tides from another site on another server (providing your server's PHP settings support it), and display the tides (as explained above) on your site. If you use that feature though you should probably get permission from the other site owner first!

Subscribe to the Weather Tech Email below to be notified about updates to this, and other scripts, and to be the first to hear about new scripts when they become available.

If you want to further process the tide data that this script outputs using your own php code, you can do so by getting it to return the output instead of echoing it. This is done by adding ",1" in the tag after the day number. Example;

<? tides(12,1); ?>

The same can be done with sun and moon rise/set, but slightly different;
<? sunmoon(12,date,1); ?>
The second variable in this function is to show or hide the date. The variable to return instead of echo the data is the third one.

 

Trouble Shooting
If you get a blank instead of tides, it's possible there is no tide information available in the tideprediction.html file for that particular day. That's possible if you use a higher number in the code tag. The script is designed to return nothing if there is nothing to return, so that it will collapse table rows for a neater appearance. Remember that each code tag only displays the tides for a single day, and that the number corresponds to the number of days ahead from today. For example, putting 10 in the tag will only display day 10, and wont display ten days worth of tides.

The sun and moon rise/set will only work if that information is available in the tideprediction.html file. This can be set in the xtide application.

The script has been designed to work with popular date formats that the tideprediction.html file uses. It will work with the following date formats only "Sunday 10-11" (dayname month-day) and "Sunday 2008-10-11" (dayname year-month-day). If the date format in your tideprediction.html file is different to the standard ones, you may need to reconfigure it in the wxtide software.

If you keep seeing a message telling you to refresh the page where your tides should be displayed, this would indicate that you have set the path to tideprediction.html incorrectly, or have put the wrong file name. The path must also include the name of your tide file. The script is designed to show the refresh message in the event that your visitor opens your tide page at the same moment that WD is uploading it, which would mean that the tide file is unavailable at that moment and your visitor would otherwise see nothing.

Subscribe to the Weather Tech Email below to be notified about updates to this, and other scripts, and to be the first to hear about new scripts when they become available.

 

Subscribe to our Weather Tech Email!

Not only can I keep you up to date with my own new scripts, script updates, and top tips, but I'm hoping to get other weather script and software developers to share their news and updates too. Use the form on the right to subscribe!

If you develop weather web scripts or software, we would like to feature your news in the Weather Tech email too! Please contact me for details.

Weather Tech Email
Stay up to date!
Email
First Name
Location




Horse Riding

Enjoy horse & pony riding at Newton Ferrers Equestrian Centre. Learn to ride at a fully equipped riding school. We also offer hacks, livery and we run a quarter horse stud.

Newton Ferrers Equus

Equestrian Classified Ads

Local gardens wanted for hedgehog release


N&N Email Service
W/E forecast & tides ..?
Daily forecast & tides ..?
Site Updates ..?
Your Email
Your First Name

You can cancel your subscription at any time.
The RYA Shorebased courses are starting next week at The Parish Rooms, Yealmpton.  We have 5 spaces left on the Day Skipper shorebased, Tues eve 7 - 9.30.  and 3 spaces left on the RYA Coastal Skipper/Yachtmaster class on Thursday eve.  Price £245.00 inclusive of books etc.  Please book on line at www.sail-westmarinechandlery.com or phone 01548 810917.. 

Under Construction!
This is part of a larger site that is currently in development. More info will be available soon.

 
   
Page loaded in 0.0058 secs.


© NewtonAndNoss.com 2001 - 2018