5,838
edits
mNo edit summary |
mNo edit summary |
||
{{TOCright}}
= Introduction =
*# these other files can be resident on your web server, they never need to be updated locally (and uploaded) as they do not need to be processed first locally.
= Using PHP script =▼
This article will first address some of the complications that make providing such a script more difficult than you might expect. This implies that you cannot have a ready made template script that will suit everyone, but also means if you are producing your own set of scripts there is quite a lot to think about. Next this article has links to a number of ready made fairly simple templates explaining which versions of Cumulus they will work with. After that this article helps you to produce your own set of templates, and finally it describes some alternative approaches.▼
If you adopt PHP Hypertext Processing on your web site; there are two main approaches:▼
#Either simply [[Customised_templates|customise]] the standard template pages by adding some PHP script that will be obeyed after the template processed by Cumulus has been
#Or write a web page including PHP code that does not need to be processed by Cumulus. To get the information that Cumulus provides, all your new pages can "'''include'''" (if you want the page to fail without that cumulus derived information - use "''require''" instead)
▲This article will first address some of the complications that make providing such a variable assigning script more difficult than you might expect.
== Web tag Complications ==
Don't think that making all web tags available as PHP variables on your web server is easy, let us see why.
=== Version specific tags ===
*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.
*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 called ''CUtags.txt'' 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.
*
**Using this array your customised pages would replace any reference to a Cumulus web tag
**A template file to do this is also called ''CUtags.txt'' and it can be downloaded from [http://saratoga-weather.org/wxtemplates/install.php Saratoga-Weather.org].▼
**That download includes elements for the recent history tags at 5, 10, 15, 20, 30, 45, 60, 75, 90, 105 and 120 minutes. If you want older values or values at other times, then you will need to add these to the array yourself.
The main focus of this article is assigning to PHP variables, but similar arguments apply for XML or JSON approaches so let us briefly review
▲The main focus of this article is assigning to PHP variables, but similar arguments apply for XML or JSON approaches so let us briefly review those.
Extensible Markup Language (XML) is a mark-up language that defines a set of rules for defining data in a format which is very focussed on being machine-readable but both software and hardware independent. Therefore it has great appeal to those writing packages that are designed to be very efficient code, very portable across different applications, where non-technical people just accept the outputs provided and don't need to understand what goes on within the black box. If you don't want to use PHP, or just don't understand how to use it, you might consider this and you will find more about this approach on the [[xml webtags|XML web tags]] page in this wiki.
▲= The Four Main Approaches to data transfer =
Some people consider XML is too complicated and a long winded way to represent variables (they would say languages like PHP are easier for humans to read), but XML was the way that Steve Loft chose to implement the Weather Diary feature in Cumulus 1, so if you want to include whether snow is falling or lying (or the text entered into the diary) in your web pages you must use a routine that reads XML within the PHP you write if you are still using Cumulus 1.
=== Option 1: Single PHP array ===▼
▲*Within it have elements for all the Cumulus web tags, choosing which parameter combinations to implement;.
▲*A file to do this is called ''CUtags.txt'' and can be downloaded from [http://saratoga-weather.org/wxtemplates/install.php Saratoga-Weather.org].
▲*That download includes elements for the recent history tags at 5, 10, 15, 20, 30, 45, 60, 75, 90, 105 and 120 minutes. If you want older values or values at other times, then you will need to add these to the array yourself.
▲*Using this array your customised pages would replace any reference to a Cumulus web tag <code><#xxyyzz optional_parameter></code> by a PHP array element <code>$WX[xxyyzz] [optional_additional_selector]</code> (some elements include the m=10 type selector).
Another approach is to create a separate PHP variable (or in a few cases an array) for each Cumulus web tag:
'''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.
The ready made templates referenced earlier use this approach.
▲=== Option 3: EXtensible Markup Language alternative ===
▲You can see more about this approach on the [[xml webtags|XML webtags]] page, but that approach is now considered an obsolete one by some who find languages like PHP easier for humans to read, while XML is considered as the best approach for the future by others (for example the WMO and ICAO have recently specified a XML and geographical based approach for reporting weather conditions at airports and are persauding those running airports to swap from METAR in traditional alphanumeric characters as introduced when the shortness of the code was easiest for transmission by telex).
▲=== Option 4: JavaScript Object Notation ===
This is a lightweight data-interchange format that is easy for humans to read and write, but critically it is easy for machines to parse and generate for transferring the variables in a portable way.
*Cumulus MX has one array per weather variable; each element being a sub-array containing a time-stamp and the value at that time. Again you may need to choose the interval between such sub-arrays that suits your use in your web pages.
▲= Using PHP script =
▲If you adopt PHP Hypertext Processing on your web site; there are two main approaches:
▲#Either simply [[Customised_templates|customise]] the standard template pages by adding some PHP script that will be obeyed after the template has been processed by Cumulus before the resulting HTML is sent to the browser.
▲#Or write a web page including PHP code that does not need to be processed by Cumulus. To get the information that Cumulus provides, all your new pages can "'''include'''" (if you want the page to fail without that cumulus information - use "''require''" instead) another single PHP file that Cumulus does process in which all the [[webtags]] values are assigned to PHP variables. This is more efficient for those using PHP on their website.
The single file idea of the second choice above might use approach option 1 or option 2, the latter is described further below.
|
edits