Php webtags

From Cumulus Wiki
Revision as of 19:47, 7 January 2015 by Sfws (talk | contribs) (→‎Usage)
Jump to navigationJump to search
Name: PHP Webtags
Type: Web templates, PHP
Author: David Jamieson
Contact: 'DAJ' via the forum
Last update: 29 Dec 2011
Version: 1.18

Cumulus automatically processes a number of template pages into HTML web pages. These template files contain webtags which Cumulus replaces with actual values from your weather station.

If you adopt PHP Hypertext Processing on your web site, you could customise those standard template pages by simply using PHP script to add extra content after the template has been processed by Cumulus.

It is more efficient for those using PHP on their website to have Cumulus process one single file and place all the webtags values into a file of PHP variables. You can include this file in all your PHP web files and use the variables as you would in PHP. In this case your customised pages would replace any reference to a Cumulus web tag <#xxyyzz> by a PHP variable $xxyyzz.

The PHP file contains all current webtags produced by Cumulus v 1.9.4 b.1099.

A similar project is available for XML webtags (Current unmaintained)


Installation

ScreenShot-PHPWebtags-ConfigSetup.png
  • place the file cumuluswebtags.txt in the Cumulus data folder (or any other location accessible by/to Cumulus);
  • on the Cumulus main screen, from the pull-down menus, select the 'Configuration' option and then the 'Internet' option;
  • on the 'Internet Settings' screen, select the 'Files' tab;
  • in one of the left side boxes (under the 'Local filenames' header), enter the name cumuluswebtags.txt:
  • -- if you have placed the file in a different location, also add the path to the file name;
  • -- you can also use the 'Browse' button to find the exact location of the file;
  • in one of the right side boxes (under the 'Remote filenames' header), enter the name cumuluswebtags.php:
  • -- if you are uploading the Cumulus files to a different server location, also add the server path to the file name;
  • -- notice that the file extension has been changed from txt (on the left side) to php (on the right side);
  • place a check mark in the box under the 'Process?' header:
  • -- this tells Cumulus that the file cumuluswebtags.txt contains tags which need to be replaced by actual values;
  • place a check mark in the box under the 'FTP?' header:
  • -- this tells Cumulus that the processed file must be uploaded to the Web server with all the other files;
  • finally, click on the lower-right 'OK' button to save the newly entered settings.

Usage

Use the PHP include/require command to include the Cumulus webtags into your PHP file.

All PHP variable names are identical to their webtags equivalent. For example, the Cumulus webtag <#forecast> would be referred to as $forecast in your PHP file.

See Sensor_Contact_PHP for an example script that uses this file.

Example

A simple PHP file:

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

The results:

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

Debugging

If you wish to view all the values contained within 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 display the source code of the file, listing all the variable names, the values Cumulus has assigned to the webtags during it's processing cycle, and a brief description of the variables/webtags.