Php webtags

From Cumulus Wiki
Revision as of 21:09, 13 December 2009 by Daj (talk | contribs) (updated version to include new tags)
Jump to navigationJump to search
Name: PHP Webtags
Type: Web templates, PHP
Author: Ray Beriau
Contact: 'gemini06720' via forum
Last update: 13 Dec 2009
Version: 1.05

Cumulus automatically prepares a number of webpages by using HTML template files. These files contain webtags which Cumulus replaces with actual values from your weather station.

For those using PHP on their website it is possible to have Cumulus process one single file and place all the webtags values in a file of PHP variables. You can include this file in all your PHP webfiles and use the variables as you would any other in PHP.

The PHP file contains all current webtags produced by Cumulus.

A similar project is available for XML webtags


Installation

ScreenShot-PHPWebtags-ConfigSetup.png
  • Rename it as cumuluswebtags.php and place it in the Cumulus data folder or any other location Cumulus can access.
  • Click the 'Configuration' menu then 'Internet'
  • In an empty slot provide the local filename where you have stored the file you just downloaded.
  • In the 'remote filenames' provide the full path and filename to upload onto your webserver.
  • Tick the 'Process' and 'FTP' boxes. This tells Cumulus that the 'local filename' contains webtags and it will replace these with actual values. The FTP option will ensure it is uploaded to your webserver with all other files.


Usage

Use the PHP include / require command to refer to the Cumulus webtags in php.

All PHP variable names are identical to their webtag names. Example: the Cumulus webtag <#forecast> is referred to in your php as $forecast


Example

A simple PHP file

<?php 
require_once("cumuluswebtags.php");
echo $time ;
echo "<br/>";
Echo "The current forecast is " . $forecast;
?>

Result:

20:31 on 02 September 2009
The current forecast is Precipitation, very unsettled

Debugging

If you wish to view all the values contained with the cumulswebtags.php file append the parameter ?source=view to the end of the URL.

Example

www.myweathersite.com/cumuluswebtags.php?source=view

This will list all the variable names, their values as set by Cumulus during it's processing, and a brief description of each webtag