Php webtags: Difference between revisions

1,233 bytes added ,  08:17, 20 April 2020
m
Line 131: Line 131:
=Option 2 - implementation details=
=Option 2 - implementation details=


The installation, usage, and example sections below apply to option 2 "cumuluswebtags.php", but are similar for the other options.
The installation, usage, and example sections below apply to a template file called "cumuluswebtags.txt", so if you are using a file with another name or multiple template files, adapt the instructions as relevant.


==Installation (with Cumulus 1) ==
== Choose your template(s) ==


##For the file you have downloaded at option 2 above, open it in any text editor (preferably one that works in "UTF-8 without BOM").
First either download a read made template, choosing from those available as listed above; or write your own template(s) following the guidance above.
##If the first line contains the following sequence of 4 characters "'''&''' '''l''' '''t''' ''';'''" then replace all of those with just one "''<''" (so the first line becomes "''<php''") NOTE - the Wiki cannot have a PHP script uploaded to it, so changing the first line stops the Wiki from treating it as PHP script, but after Cumulus has processed it (Cumulus does not care what it processes, but will copy anything it does not recognise across unchanged) we do want the generated file to be treated as a PHP script.
 
#Next add any parameter combinations that you need for your own implementation. For example, for my implementation, I found that my customisation of the template version had used many more Cumulus web tags with parameters than I expected, consequently my cumuluswebtag.cum template file has (amongst others) the following extras
== Edit your template(s) ==
#*$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">';
If you have chosen a ready made template, or have realised you need a PHP variable for a different set of parameters to those coded already, you will need to edit your template.
#*$LastTimeStamp='<#LastDataReadT format="h:nn 'on' d mmm">';
 
#*$metdateM='<#metdate format="mmm">';
# It is best to use an editor that allows you to choose the encoding for the file it saves. Any editor designed for editing code should do this (e.g. Notepad++), but word processors and the popular online editors will add unwanted extra characters. The best encoding for files to work with Cumulus is  "UTF-8 without BOM".
#*$metdateMM='<#metdate format="mmmm">';
# Open your file in your chosen editor.
#*$monthYear='<#metdate format="mmmm yyyy">';
#*If the first line contains the following sequence of 4 characters "'''&lt;'''" then replace those 4 characters with a single "''<''" (so the first line becomes "''<php''") NOTE - the Wiki cannot have a PHP script uploaded to it, so changing the first line stops the Wiki from treating it as PHP script, but after Cumulus has processed it (Cumulus does not care what it processes, but will copy anything it does not recognise across unchanged) we do want the generated file to be treated as a PHP script.
#*$monthStart='<#metdate format="yyyy-mm-01">';
#Add any new web tags that have been added for the Cumulus version you are using, that were not available when the template was created.
#you can also delete any rows with web tags that are not relevant to your weather station model for greater efficiency;
#Next look at any web tags that can take input and/or output parameters; add any parameter combinations that you need for your own implementation.  
#then save the resulting file in the local directory (that Cumulus can read) where you store your customised templates (you could use the "cumuluswebtagsT.cum" type convention as I do because of all my customisations, but to keep it simple the suggestion here is to retain the name as "cumuluswebtags.txt" if you are basically using the provided code).[[File:ScreenShot-PHPWebtags-ConfigSetup.png|right|'Screenshot top and bottom extracts Cumulus v1.9.4']]
#*For example, for my implementation, I found that my customisation of the template version had used many more Cumulus web tags with parameters than I expected, consequently my cumuluswebtag.cum template file has (amongst others) 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">';
#**$metdateM='<#metdate format="mmm">';
#**$metdateMM='<#metdate format="mmmm">';
#**$monthYear='<#metdate format="mmmm yyyy">';
#**$monthStart='<#metdate format="yyyy-mm-01">';
#Next delete any rows with web tags that are not relevant to your weather station model for greater efficiency;
# Finally save your edited template file or files in either the "web" directory where Cumulus has the files it will process or where you store your customised templates.
#* The choice of filename and extension is up to you, it might make sense to use a different name or extension (e,g. "cumuluswebtagsT.cumMX"), if you have edited the file to be sure you don't confuse it and the original and you know which version of Cumulus it is for.
#* If you have several templates being uploaded at different intervals you might choose names like "webtagsRealtimeT.txt", "webtagsNormalT.txt" and "webtagsEoDT.txt".
 
Here is a screenshot for Cumulus 1 using the name as "cumuluswebtags.txt" if you are basically using the provided code).[[File:ScreenShot-PHPWebtags-ConfigSetup.png|right|'Screenshot top and bottom extracts Cumulus v1.9.4']]
#On the 'Cumulus main screen', in the '''Configuration''' menu, select the ''Internet'' option;
#On the 'Cumulus main screen', in the '''Configuration''' menu, select the ''Internet'' option;
#On the 'Internet Settings' screen, select the ''Files'' tab;<br><br>
#On the 'Internet Settings' screen, select the ''Files'' tab;<br><br>
5,838

edits