Webtags (preserving history): Difference between revisions

m
mNo edit summary
Line 162: Line 162:
* changing number of decimal places, and  
* changing number of decimal places, and  
* removing decimal commas.
* removing decimal commas.
== Cumulus Templates ==
=== Using web tags in templates for creating HTML pages ===
*You can create a template file that has a structure of HTML elements with Cumulus web tags to represent the information you want included.
*If you  [[Customised_templates#What_to_select_on_the_.27Files.27_tab_of_the_Internet_Settings_screen_within_the_.27Configuration.27_menu|ask Cumulus to process]] that template file, it will create a HTML page from the template, and during that file creation replace the tag with the current value of the item the tag represents.
*You also need to tell Cumulus that the resulting HTML file is to be uploaded to the internet (or copied to a local web server).
=== Using web tags in scripts ===
*You can also use the tags within script, this might be a PHP script, or JavaScript either embedded in HTML, or in external files, to transfer the values (or the result of calculations based on those values) to your web server for further processing.
*As JavaScript can not understand a real number that has the integer and decimal parts separated by a comma, but your computer may be set to use that representation in standard tags, there are special versions of many tags to use in script - see [[#No_Commas|tags with commas removed]] section.
*Note that if a PHP or JavaScript file contains any Cumulus web tags then you must [[Customised_templates#What_to_select_on_the_.27Files.27_tab_of_the_Internet_Settings_screen_within_the_.27Configuration.27_menu|ask Cumulus to process]] the script file.
*JavaScript processing code can be embedded in a template that is already being processed into HTML. (This technique has been used  in the standard 'monthlyrecordT.htm' template).
*Alternatively embed a bit of JavaScript assignment code in HTML, that is already been processed, to convert the tags to a collection of string variables and use those variable names in any external script called from the HTML file. (This technique has been used in the standard 'gaugesT.htm' template).
*To use the value from a tag as an integer in JavaScript assigning code you need to use a
<pre>integer_variable_name=parseInt(string_variable_name,10)</pre> type conversion
*To use a value from a tag as a floating point number in JavaScript you need to use <pre>parseFloat(string_variable_name)</pre> otherwise you will find any attempt to add something to it results in a concatenation because JavaScript uses "+" for two purposes and concatenation takes precedence over arithmetic adding!
*Alternatively, in most script languages, apply ' * 1', i.e. multiply by one, to implicitly convert the tag from string to base 10 number.
*Another alternative is to add zero when a web tag is being assigned to a script variable, this is frequently used in scripts where the web tag being used is not available in all versions of Cumulus, because Cumulus does not implement the concept of null values and often zero is used when a true value is not available because that sensor is not installed for example. Adding 0 means that if the web tag is not recognised, the script is still able to give a variable in its language some value and won't fail because that variable is undefined. If the web tag is available, adding zero does not prevent the true value of that web tag being assigned to the variable.
== Web Tag Differences Between Cumulus 1 and MX builds ==
{{Version badge 1}}
This badge is used when the web tags listed in one of the tables are available in the final 1.9.4 release of Cumulus 1, but not in MX.  When Cumulus 1 is processing web tags, it tends to ignore any it cannot understand, so look for gaps in your web pages to find errors.
[[File:Badge vMx.png]]
Cumulus MX provides many, but not all web tags that were available in Cumulus 1. MX adds many more web tags, mostly in support of new weather stations or new sensors. This badge is used against web tags listed in one of the tables that are only available in MX. See [[#GENERAL_TIP|tip]] at top of page for how to check which web tags are available in your build.
A combination of badges appears where certain aspects apply to Cumulus 1 or to MX. No information is given for Cumulus 2 as it is no longer available.
When MX is processing web tags and finds one it cannot understand, a "*** web tag error - see MXdiags file ***" message will appear in the engine console, and the diagnostic file will include something like this, be aware a "token" parser is used to evaluate web tags:
<pre>Web tag error
Exception: i=8998 len=106297
inputText.Length=106297
token=<#daylightlength format=H></pre>
This particular error is that when you use a single output format character it does not have same meaning as when there are multiple characters, correct this particular web tag to:
<pre><#daylightlength format=%H></pre>
Please note that where this article makes reference to other pages in the Wiki, the information shown there might be specific to Cumulus 1, as there are differences between the user interface for Cumulus 1 and MX flavours of this software, and the Wiki was originally written before MX existed, so not all pages have been updated.


=Output 'format' Parameter=
=Output 'format' Parameter=
5,838

edits