Php webtags: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
(initial creation)
 
Line 31: Line 31:
<pre>
<pre>
<?php  
<?php  
require("cumulustags.php");
require_once("cumulustags.php");
echo $time ;
echo $time ;
echo "<br/>";
echo "<br/>";
Line 42: Line 42:
<pre>20:31 on 02 September 2009
<pre>20:31 on 02 September 2009
The current forecast is Precipitation, very unsettled</pre>
The current forecast is Precipitation, very unsettled</pre>


=Debugging=
=Debugging=

Revision as of 10:53, 3 September 2009

Name: PHP Webtags
Type: Web templates, PHP
Author: Ray Beriau
Contact: 'gemini06720' via forum
Last update: 17 Aug 2009
Version: 1.01

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.


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("cumulustags.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 ?sce=view to the end of the URL.

Example

www.myweathersite.com/cumuluswebtags.php?sce=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