Php webtags: Difference between revisions

840 bytes added ,  11:22, 8 January 2015
m
no edit summary
mNo edit summary
Line 1: Line 1:
{{AddOnBanner|name=PHP Webtags|type=Web templates, PHP|author=David Jamieson|contact='DAJ' via the forum|updated=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.
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 [[Customised_templates|customise]] those standard template pages by simply using PHP script to add extra content after the template has been processed by Cumulus.
If you adopt PHP Hypertext Processing on your web site, you could [[Customised_templates|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.
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.
=Options available=
# One approach is to create an array '''$WX''' and within it have elements for all the Cumulus web tags.  A file to do this is called ''CUtags.txt'' and can be downloaded from [http://saratoga-weather.org/wxtemplates/install.php Saratoga-Weather.org].  That approach includes elements for the recent history tags at 5, 10, 15, 20, 30, 45, 60, 75, 90, 105 and 120 minutes.  In this case your customised pages would replace any reference to a Cumulus web tag <#xxyyzz> by a PHP array element $WX[xxyyzz].
# Another approach is to create a PHP variable for each Cumulus web tag. In this case your customised pages would replace any reference to a Cumulus web tag <#xxyyzz> by a PHP variable $xxyyzz. This is done by the file cumuluswebtags.tx, and this PHP file (download link below) contains all current [[webtags]] produced by Cumulus v 1.9.4 b.1099, but as supplied the recent history tags are commented out and if you want to use them you need to put in the necessary time selectors yourself.
# There was another project [[xml webtags|XML webtags]] but that is now obsolete.
# Yet another approach would be to use JSON for transferring the variables in a portable way. That has been proposed, but no standard approach has yet been developed.
==Installation ==
Download [http://wiki.sandaysoft.com/files/cumuluswebtags.txt cumuluswebtags.txt  link];


The PHP file contains all current [[webtags]] produced by Cumulus v 1.9.4 b.1099.
A similar project is available for [[xml webtags|XML webtags]] (Current unmaintained)
=Installation=
Download [http://wiki.sandaysoft.com/files/cumuluswebtags.txt cumuluswebtags.txt  link];
[[File:ScreenShot-PHPWebtags-ConfigSetup.png|right|'Screenshot top and bottom extracts Cumulus v1.9.4']]
[[File:ScreenShot-PHPWebtags-ConfigSetup.png|right|'Screenshot top and bottom extracts Cumulus v1.9.4']]
# Choose a local directory (that Cumulus can read) where you store your customised templates as the destination for this download, or copy the file there after download;
# Choose a local directory (that Cumulus can read) where you store your customised templates as the destination for this download, or copy the file there after download;
Line 32: Line 31:
# Finally, click on the lower-right '''OK''' button to save the newly entered settings.
# Finally, click on the lower-right '''OK''' button to save the newly entered settings.


=Usage=
==Usage==


Use the PHP [http://www.w3schools.com/PHP/php_includes.asp include/require] command to include the Cumulus webtags into your PHP file.   
Use the PHP [http://www.w3schools.com/PHP/php_includes.asp include/require] command to include the Cumulus webtags into your PHP file.   
Line 40: Line 39:
See [[Sensor_Contact_PHP]] for an example script that uses this file.
See [[Sensor_Contact_PHP]] for an example script that uses this file.


=Example=
==Example==


A simple PHP file:
A simple PHP file:
Line 60: Line 59:
</pre>
</pre>


=Debugging=
==Debugging==


If you wish to view all the values contained within the '''cumulswebtags.php''' file, append the parameter <tt>?source=view</tt> to the end of the URL.   
If you wish to view all the values contained within the '''cumulswebtags.php''' file, append the parameter <tt>?source=view</tt> to the end of the URL.   
5,838

edits