Php webtags: Difference between revisions

603 bytes added ,  05:10, 20 April 2020
m
Line 42: Line 42:
2. One convention is to make the php_variable_name match the cumulus_tag_name. This breaks down if you use names like $version for other purposes, or if you get confused by the random naming standard adopted by Steve Loft (some yesterday tags have Y at end, some don't, sometimes Y means yesterday, other times Y means yearly), so feel feel free to invent you own consistent naming standard.  
2. One convention is to make the php_variable_name match the cumulus_tag_name. This breaks down if you use names like $version for other purposes, or if you get confused by the random naming standard adopted by Steve Loft (some yesterday tags have Y at end, some don't, sometimes Y means yesterday, other times Y means yearly), so feel feel free to invent you own consistent naming standard.  


3. If the cumulus web tag always returns a numeric value, it is better to leave off the quotes, because then it can be used in PHP arithmetic more easily. To discover all available web tags for the Cumulus version you are using see [[Webtags|top of Web tags page]].
3. If the cumulus web tag always returns a numeric value, it is better to leave off the quotes, because then it can be used in PHP arithmetic more easily. To discover all available web tags for the Cumulus version you are using see [[Webtags|top of Web tags page]]. See the examples at the start of this article for some monthly tags that don't return numerical values on the first day of a month.


4. I have shown single quotes there, but they do not always work, see the discussion about problems with delimiting strings at [https://cumulus.hosiene.co.uk/viewtopic.php?f=4&t=1 this cumulus support forum link].
4. I have shown single quotes in my example, but they do not always work, see the notes at the start of this page, there is further discussion about problems with delimiting strings at [https://cumulus.hosiene.co.uk/viewtopic.php?f=4&t=1 this cumulus support forum link].


5. In the format example, I mention input parameters, see the [[Webtags|Web tags]] page for full details of where you can use them, but they might indicate what information you are seeking if like '''Recent History''' you can get values for a range of different times. I also mention output formats, these are also explained on the web tags page, but they might select whether a time is shown in am/pm format or 24-hour format, whether a date uses the full month name or a number and so on.  You might want to quote the same web tag with different selections and either assign each to a different variable name or to a different element of an array variable.
5. In the format example, I mention input parameters, see the [[Webtags|Web tags article]] page for full details of where you can use them, but they might indicate what information you are seeking if like '''Recent History''' you can get values for a range of different times. I also mention output formats, these are also explained on the web tags page, but they might select whether a time is shown in am/pm format or 24-hour format, whether a date uses the full month name or a number and so on.  You might want to quote the same web tag with different selections and either assign each to a different variable name or to a different element of an array variable.


6. You can include PHP comments any where you like, if on a separate line delimit by "/*" to "*/", if at end of line prefix by "#" or "//". Don't put any special characters at the end of this file, it will become pure PHP, and that never uses a terminator "?>". The teminator is needed only in mixed content files when there are HTML statements after the terminator.
6. You can include PHP comments any where you like, if on a separate line delimit by "/*" to "*/", if at end of line prefix by "#" or "//". '''Don't put any special characters''' at the end of this file, it will become '''pure PHP''', and that '''never uses a terminator''' "?>". That terminator is needed only in mixed content files when there are HTML statements after the terminator.


7. I say above "1 or more template files". Since you can tell Cumulus to process/upload files at different intervals, you might want to include those web tags that change frequently (now and today for example) in a template file that you will action at the real time interval, and include those web tags that rarely change (e.g. yesterday, station-related, units) in a template file that is only uploaded at end of day. Yet another template file can be uploaded at normal updating interval, that might include the monthly and yearly tags for example. You decide what suits your own restrictions on total size of files to upload at different frequencies.
7. I say above "1 or more template files". Since you can tell Cumulus to process/upload files at different intervals, you might want to include those web tags that change frequently (now and today for example) in a template file that you will action at the real time interval, and include those web tags that rarely change (e.g. yesterday, station-related, units) in a template file that is only uploaded at end of day. Yet another template file can be uploaded at normal updating interval, that might include the monthly and yearly tags for example. You decide what suits your own restrictions on total size of files to upload at different frequencies.
Line 61: Line 61:
'''For more information''' on how to write a template file or how to ask Cumulus to process files see [[Customised_templates#What_is_meant_by_.27Cumulus_processes_templates.27|processed by Cumulus]] topic.
'''For more information''' on how to write a template file or how to ask Cumulus to process files see [[Customised_templates#What_is_meant_by_.27Cumulus_processes_templates.27|processed by Cumulus]] topic.


'''Instead of producing your own template''', there are a number already produced, ''none of them cover all web tags'', but they might cover enough for your purposes:
==== Ready made PHP Web Tag templates ====
'''Instead of producing your own template''', there are a number already produced (if they contain output parameters they are specific to a particular flavour of Cumulus), of course ''none of them cover all web tag combinations'' possible using output parameters, but they might cover enough for your purposes:


*The download file on '''this page''' (download [[File:Cumuluswebtags.txt]]) contains all current [[webtags]] produced by Cumulus v 1.9.4. '''IMPORTANT''' This file is only for use with Cumulus v1.9.4, it will not work with [[Cumulus MX|Cumulus 3 (MX)]]. Note that in this download 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.
*For version 3.5.3 (build 3074), a single template file can be downloaded from [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=17991 CumulusMX PHPwebtags] topic in the support forum, posted by the administrator (water01).
*You may prefer the template that you can download at [https://cumulus.hosiene.co.uk/viewtopic.php?f=6&t=10424&sid=123ca9bf91d769094eed72096c7920ea&start=15#p99549 by Brandon in this cumulus support forum link]. It should work for Cumulus 1 or MX.
* An equivalent for MX version 3.0.x is at [https://cumulus.hosiene.co.uk/viewtopic.php?f=39&t=13252&p=103860&hilit=cumuluswebtags.txt#p103830 this page on  support forum] posted by the administrator (water01), but that was last edited in 2015 and does not contain any web tags added since then.
* An equivalent for MX only is at [https://cumulus.hosiene.co.uk/viewtopic.php?f=39&t=13252&p=103860&hilit=cumuluswebtags.txt#p103830 this page on  support forum] posted by the administrator (water01), but that was last edited in 2015 and does not contain any web tags added since then.
*For the final version 1.9.4 of Cumulus 1 use the download file on '''this page''' (download [[File:Cumuluswebtags.txt]]). Note that in this download 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.  Edit this template file to put in the necessary time selectors yourself.
* Another version that works with both Cumulus 1 and MX is at [https://cumulus.hosiene.co.uk/viewtopic.php?f=40&t=17985&p=140688#p140688 this post of mine in a zip] produced by BCJKiwi, this one does not contain any web tags that are only available in MX.
*An alternative simpler template, that should work for Cumulus 1 or MX as it does not contain any output parameters, can be downloaded at [https://cumulus.hosiene.co.uk/viewtopic.php?f=6&t=10424&sid=123ca9bf91d769094eed72096c7920ea&start=15#p99549 by Brandon in this support forum link].
* Another simple template produced by BCJKiwi that works with both Cumulus 1 and MX is at [https://cumulus.hosiene.co.uk/viewtopic.php?f=40&t=17985&p=140688#p140688 this post of mine in a zip], this one does not contain any web tags that are only available in MX, nor does it contain any that require output parameters.


=== Option 3: EXtensible Markup Language alternative ===
=== Option 3: EXtensible Markup Language alternative ===
5,838

edits