Php webtags

From Cumulus Wiki
Revision as of 21:17, 8 April 2011 by Daj (talk | contribs) (Updated for version 1.9.1 or Cumulus)
Jump to navigationJump to search
Name: PHP Webtags
Type: Web templates, PHP
Author: David Jamieson
Contact: 'DAJ' via the forum
Last update: 06 April 2011
Version: 1.15

Cumulus automatically prepares a number of Web pages 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 into a file of PHP variables. You can include this file in all your PHP webfiles and use the variables as you would in PHP.

The PHP file contains all current webtags produced by Cumulus. (402 webtags as per version 1.9.1)

A similar project is available for XML webtags


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.


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.