5,838
edits
m (→Installation) |
m (Re-structuring) |
||
|
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
#Either Simply [[Customised_templates|customise]] those standard template pages by adding some PHP script that will be obeyed after the template has been processed by Cumulus before the resulting HTML is sent to the browser.
#Or write a web page including PHP code that does not need to be processed by Cumulus. To get the information that Cumulus provides, all your new pages can "'''include'''" (if you want the page to fail without that cumulus information - use "''require''" instead) another single PHP file that Cumulus does process in which all the [[webtags]] values are assigned to PHP variables. This is more efficient for those using PHP on their website.
=Options available=
*In early versions of Cumulus, its web tags did not take parameters and it was easy to assign each web tag to a variable that PHP could use;
*From version 1.9.3 various web tags (such as "Recent History") always take parameters, others (like those reporting times and/or dates) can take parameters. There are now a vast number of possible combinations and it would be in-efficient for all those combinations to be generated whether needed or not. Consequently anyone devising a sample file in any of the formats listed below can only guess which parameters are most useful.
*Note that Cumulus web tags can return either numerical or string information, and when returning string information Cumulus can include embedded quotes: e.g. <code>$LatestError = "Latest Error: 'Some filename was locked" recorded';</code> as the embedded ones are double quotes, single quotes are used in <code>$LatestError='<#LatestError>';</code> in the template file as delimiters for the whole string. Equally Longitude and Latitude web tags by default label the minutes and seconds part with the same symbols as used by quotes, so we have to choose the alternative decimal notaion <code>$longitude=<#longitude dp=5>;</code>
*Yet another complication (for Cumulus 1 users) is that the values for [[Webtags#Time.2FDate_.27format.27_Parameter|formatting parameters]] can include double and single quotes, but any assignment to a PHP variable requires the value to be quoted so it is treated as a string. There are two ways round this, one is to concatenate several uses of the same Cumulus web tag to build up the required layout without using both versions of quotation marks within any single formatting value e.g. <code>$LastDataReadTDM='<#LastDataReadT format=h:nn'.' on '.'<#LastDataReadT format="d mmm">';</code>, and the other is to use the PHP 'heredoc' approach - see PHP manual.
All the examples above are assigning to PHP variables, but similar arguments apply for XML or JSON approaches.
<br/>
'''The Four Main Approaches'''
# One approach is to create an array '''$WX'''
#*Within it have elements for all the Cumulus web tags, choosing which parameter combinations to implement;.
#*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
# Another approach is to create a separate PHP variable (or in a few cases an array) for each Cumulus web tag.
#*In this case your customised pages would replace any reference to a Cumulus web tag <code><#xxyyzz optional_parameter></code> by a PHP variable or array - either <code>$xxyyzz[optional_index]</code> or <code>$xyyxwx</code>.
#*In your customised pages, use the instruction '''require cumuluswebtags.php'''.
#*To produce this PHP file, you need a template file (download [[File:Cumuluswebtags.txt]]) that is [[Customised_templates#What_is_meant_by_.27Cumulus_processes_templates.27|processed]] by Cumulus.
#*For
#*For a discussion about problems with delimiting strings see [http://sandaysoft.com/forum/viewtopic.php?f=4&t=1 another cumulus support forum thread link].
#*The download file contains all current [[webtags]] produced by Cumulus v 1.9.4.
#*Note that as supplied the recent history tags only occur with a single 3 hours ago parameter but if you use these tags it is likely you will want to include them for several other periods too so if you want to use them you need to put in the necessary time selectors yourself.<br/><br/>
# There was another project [[xml webtags|XML webtags]] but that is now obsolete.<br/><br/>
# An alternative approach is to use JSON for transferring the variables in a portable way.
#*Cumulus MX has one array per weather variable; each element being a sub-array containing a time-stamp and the value at that time. Again you may need to choose the interval between such sub-arrays that suits your use in your web pages.
=Option 2 - implementation details=
The installation, usage, and example sections below apply to option 2 "cumuluswebtags.php", but are similar for the other options.
==Installation ==
#For the file you have downloaded at option 2 above, open it in any text editor
#Next add any parameter combinations that you need for your own implementation. For example, for my site I replaced '''thismonthT.htm''' with '''thismonth.php''' and found that my customisation of the template version had used many more Cumulus web tags with parameters than I realised, consequently my cumuluswebtag file has the following extras
#*$LastDataReadTDM='<#LastDataReadT format=h:nn'.' on '.'<#LastDataReadT format="d mmm">';
#*$LastDataReadTDMY='<#LastDataReadT format="h:nn am/pm"> on calendar day <#LastDataReadT format="dddd d mmmm yyyy">';
#*$LastTimeStamp='<#LastDataReadT format="h:nn 'on' d mmm">';
# On the 'Internet Settings' screen, select the ''Files'' tab;<br><br>▼
#*$metdateM='<#metdate format="mmm">';
# Edit the screen columns as indicated by red in the figure:▼
#*$metdateMM='<#metdate format="mmmm">';
#* in one of the local side boxes (under the 'Local filenames' header), enter the path (directory\file) to where you have stored the template:<br>e.g. '''your_customised_template_location\cumuluswebtags.txt'''<br> (you can use the 'Browse' button to find and select the exact location of the file);<br><br>▼
#*$monthYear='<#metdate format="mmmm yyyy">';
#* in one of the remote side boxes (under the 'Remote filenames' header), enter the name '''cumuluswebtags.php''':▼
#*$monthStart='<#metdate format="yyyy-mm-01">';
#you can also delete any rows with web tags that are not relevant to your weather station model for greater efficiency;
#** (-- if you are using a local server, and want Cumulus to do a 'copy' instead of using 'FTP' then specify the full path to the file here);▼
#then save the resulting file in the local directory (that Cumulus can read) where you store your customised templates (rather than use the "cumuluswebtagsT.php" type convention, the suggestion is to retain the name as "cumuluswebtags.txt".[[File:ScreenShot-PHPWebtags-ConfigSetup.png|right|'Screenshot top and bottom extracts Cumulus v1.9.4']]
#** -- notice that the file extension has been changed from '''txt''' (on the left side) to '''php''' (on the right side) as the remote file needs to be recognised by the PHP processor on the web server;▼
#
▲#*
▲#*
#** -- if needed add the relative server path (see Cumulus Help for explanation) before the file name;
▲#** (-- if you are using a local server, and want Cumulus to do a 'copy' instead of using 'FTP' then specify the full path
▲#** -- ''notice that the file extension has been changed from'' '''txt''' (on the left side) to '''php''' (on the right side) ''as the remote file needs to be recognised by the PHP processor on the web server;''
#** -- this tells Cumulus that the file '''cumuluswebtags.txt''' contains tags which need to be replaced by actual values when it processes the template into a web page;
#*(there is no red arrow under the 'Realtime' header as it is normally not appropriate, but if any of your PHP pages are using this file because they require any web tags not in the realtime file, then you might need to select this option);
▲#* place a check mark in the box under the 'FTP?' header:
#*place a check mark in the box under the 'UTF-8' header;
#* place a check mark in the box under the 'FTP?' header;
#** -- this tells Cumulus that the processed file must be uploaded by file transfer to the remote Web server with all the other files;
#** (if you use a local web server, you can leave this un-checked and Cumulus will copy across the processed file to the location specified in the right hand box, but for this you need to specify the full path there);
| |||
edits