Php webtags: Difference between revisions

2,721 bytes added ,  11:46, 20 April 2020
m
Line 63: Line 63:
== 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:
'''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:


*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) as an update to the one below.
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]].
*An equivalent for 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] also posted by the administrator (water01), and developed from the original by David Jamieson and Ray Beriau. This one does not contain any web tags added since 2015, but use this one also for versions before 3.5.3 to avoid any errors being reported and accept it may not include some of the web tags available in in-between versions. Most php variable names match the corresponding web tags name, but there are some extra PHP variable names for web tags with particular output parameters. For example:
 
<pre>$date2                     = strtotime(str_replace('/','-',"<#date>"));  //  current date (example format: 1346569200)
 
$dateU                     = strtotime(str_replace('/','-',"<#date>"));  //  current date (Unix datestamp format)
=== Based on original by David Jamieson and Ray Beriau ===
$datelong                   = "<#date format="dddd, MMMM dd, yyyy">";  //  current date (example format: Monday, January 23, 2011)
These all work with Cumulus 1. They all contain PHP variables for all the web tags available in Cumulus 1. 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. For recent history tags the PHP variables are set to report only the values for one day and one minute ago. 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.
$dateshort                 = "<#date format="MMM dd, yyyy">";  //  current date (example format: Jan 23, 2011)</pre>
<pre>$date2           = strtotime(str_replace('/','-',"<#date>"));  //  current date (example format: 1346569200)
$dateU             = strtotime(str_replace('/','-',"<#date>"));  //  current date (Unix datestamp format)
$datelong           = "<#date format="dddd, MMMM dd, yyyy">";  //  current date (example format: Monday, January 23, 2011)
$dateshort         = "<#date format="MMM dd, yyyy">";  //  current date (example format: Jan 23, 2011)
$LastDataReadT2    = strtotime(str_replace('/','-',"<#LastDataReadT>"));
$LastDataReadTU    = strtotime(str_replace('/','-',"<#LastDataReadT>")); // (Unix timestamp format)
$time2              = strtotime("<#time format="hh:mm MMMM dd yyyy">");
$timelong          = "<#time format="hh:mm 'on' MMMM dd, yyyy">";  //  current time (example format: 12:34 on January 01, 2011)
$timeshort          = "<#time format="hh:mm">";  //  current time (example format: 12:34)
$timedatelong      = "<#time format="MMMM dd, yyyy">";  //  current date time (example format: January 01, 2011)
$timedateshort      = "<#time format="MMM dd, yyyy">";  //  current date time (example format: Jan 01, 2011)
$timeUTC2          = strtotime(str_replace('on ','',"<#timeUTC>"));  //  UTC (GTM) time (example format: 12:34 on 01 January 2011)
$timeUTCstd        = "<#timeUTC format="hh:mm 'on' MMMM dd, yyyy">";  //  UTC (GTM) time (example format: 12:34 on January 01, 2011)
$timeUTC_dd        = "<#timeUTC format=dd>";  //  UTC (GTM) time - date number (example format: 01)
$timeUTC_mm        = "<#timeUTC format=MM>";  //  UTC (GTM) time - month number (example format: 01)
$timeUTC_yyyy      = "<#timeUTC format=yyyy>";  //  UTC (GTM) time - year number (example format: 2011)
//$timeUTC_all    = "<#timeUTC format="yyyy' - 'MM' - 'dd' - 'hh' - 'MM">";  //  UTC (GTM) time (example format: 2011 - 01 - 01 - 12 - 34)
$timeUTC_all      = "<#timeUTC format="yyyy">|<#timeUTC format="MM">|<#timeUTC format="dd">|<#timeUTC format="hh">|<#timeUTC format="MM">";  //  UTC (GTM) time (example format: 2011 - 01 - 01 - 12-34)
$updated                    = "<#update format="'at' hh:mm:ss 'on' MMMM dd">";  //  date and time of the last web site update (example format: at 18:30:55 on 01 Jan)
$updateU                    = strtotime(str_replace('/','-',"<#update>"));  //  (Unix timestamp format)</pre>




*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) as an update to the one below.
*An equivalent for 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] also posted by the administrator (water01), and developed from the . This one does not contain any web tags added since 2015, but use this one also for versions before 3.5.3 to avoid any errors being reported and accept it may not include some of the web tags available in in-between versions.
*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.
*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.
** The advantage of only choosing one possible input parameter is that this template can use PHP variable names that match the web tag name, and only use PHP arrays when the web tag returns an array.
** The advantage of only choosing one possible input parameter is that this template can use PHP variable names that match the web tag name, and only use PHP arrays when the web tag returns an array.


=== Alternatives ===
=== Alternatives ===
 
These templates have not been influenced by the original template, but instead have tried to cover every web tag available at the time the template was written, and each author has made their own independent decision about what parameters to use.
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]].


*An alternative simpler template, can be downloaded in [https://cumulus.hosiene.co.uk/viewtopic.php?f=6&t=10424#p99549 this storm rain topic], it was generated by Brandon using all web tags available in November 2014 but without using any output parameters. It was specifically for anyone using a Davis so it contains storm rain.
*An alternative simpler template, can be downloaded in [https://cumulus.hosiene.co.uk/viewtopic.php?f=6&t=10424#p99549 this storm rain topic], it was generated by Brandon using all web tags available in November 2014 but without using any output parameters. It was specifically for anyone using a Davis so it contains storm rain.
5,838

edits