Php webtags: Difference between revisions

1,746 bytes added ,  10:50, 25 April 2020
m
Line 104: Line 104:
== Ready made PHP Web Tag templates ==
== Ready made PHP Web Tag templates ==


'''Instead of producing your own template''' as described in '''Option 2''' below, 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:
It is perfectly possible to produce your own templates, following the advice in '''Option 2''' below, I know that might scare you.
*One approach, that is perhaps easier is to modify a ready-made script (as has happened for some of those listed below) by adding new lines, each with a PHP variable name (it must start with "$") on the left of an equals sign and a web tag (<#tag_name>) on the right, and end the line with a ";".
*You can add a comment at end of line using prefix "//".
*In this way, you can add anything missing from the PHP variables in the existing template.
*You don't need to know any more about PHP than I have said above (requirement for "$" and ";").
*All you need is an understanding of the web tag syntax gained from studying the [[Webtags|Web tags]] wiki page.
*The scary bit is understanding the right format to use in those web tags for the output parameters because it is easy to specify items like minutes, hour, or month, incorrectly.


Be aware that if you are using Cumulus 1, it ignores any web tags it does not recognise. If you are using MX it issues a warning and a detailed error report for any web tag that is either not recognised in the particular version you are using or has output parameters where the interpretation is unclear. The latter is because parameters like 'h' and 'M' have different interpretations depending on context and might need a '%' before them as explained on [[Webtags|Web tags page]].
Given all the web tag complications discussed above, you made find a ready made template that suits you from those listed below, remember to check if it is specific to whichever flavour of Cumulus you use, remember of course ''none of them cover all web tag combinations'' possible using output parameters, but they might cover enough for your purposes:
 
*Be aware that if you are using Cumulus 1, when processing it ignores any web tags it does not recognise.  
*If you are using MX when that is processing your file it issues a warning and a detailed error report for any web tag that is either not recognised in the particular version you are using or has output parameters where the interpretation is unclear. The latter is because parameters like 'h' and 'M' have different interpretations depending on context and might need a '%' before them as explained on [[Webtags|Web tags page]].




=== Based on original by David Jamieson and Ray Beriau ===
=== Based on original by David Jamieson and Ray Beriau ===
These all work with Cumulus 1. They all contain PHP variables for all the web tags available in Cumulus 1.  
They all contain PHP variables for all the web tags available in Cumulus 1, some contain all web tags available in MX. You will notice the USA style month first bias of the original authors in some of the date formats below, and consequently a few of the PHP variables might not work perfectly in other locales, all depending of course on which of the defined PHP variables you actually use.


For the files marked as for MX versions, the PHP variables that relate to web tags not available in  MX have been given arbitrary fixed values, not nulls, so only really work for the system of the person who last updated the file.  
For the files marked as for MX versions, the PHP variables that relate to web tags not available in  MX have been given arbitrary fixed values, not nulls, so only really work for the system of the person who last updated the file.  


For recent history tags the PHP variables are set to report only the values for one day and one minute ago. These are used on a "Now" type page that compares the current values to the values at the closest time yesterday. The extra minute has to be added to the output parameters to cover the delay in retrieving the old values compared to the speed in updating of current values.
For recent history tags the PHP variables are set to report only a few of the 9 million combinations:
#In one approach, for each recent history web tag the PHP variable is set to the values for one day and one minute ago. These are used on a "Now" type page that compares the current values to the values at the closest time yesterday. The extra minute has to be added to the output parameters to cover the delay in retrieving the old values compared to the speed in updating of current values.
#In another approach, a string is reported for each recent history web tag. That string contains 3 numeric values each separated by a "|". The first part is the value for 1 day ago (d=1), the middle for one hour ago (h=1), and the last for one minute ago (m=1). I am not sure why that combination was chosen, but you would need to understand how to use the PHP function "explode('|',variable_name)" to extract the values.


Otherwise, apart from a few web tags that report dates where alternative formats are added (as shown below) using output parameters and new variable names, most php variable names match the corresponding web tags name, there are no alternatives for the time-stamps and date-stamps in any weather derivatives. You will notice the USA style month first bias of the original authors in some of the date formats below.
Otherwise, apart from a few web tags that report dates where alternative formats are added (as shown below) using output parameters and new variable names, most php variable names match the corresponding web tags name, there are no alternatives for the time-stamps and date-stamps in any weather derivatives.  


'''Note there is an error in every single one of these files''' - they contain a "?>" at the end, that should not be used in pure PHP files - see PHP manual instruction.  Should white-space or new lines being added after the PHP closing tag, even accidentally,  there may be unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script. That applies even if the extra is after the include/require in the script using this file.
'''Note there is an error in every single one of these files''' - they contain a "?>" at the end, that should not be used in pure PHP files - see PHP manual instruction.  Should white-space or new lines being added after the PHP closing tag, even accidentally,  there may be unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script. That applies even if the extra is after the include/require in the script using this file.
5,838

edits