Customised templates: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
 
== Changing how an extreme is shown ==
 
Most Cumulus web pages show extremes with first the label being shown in a tabel cell containing text, then comes a table cell with the value and unit (both of these will normally be Cumulus web tags) and finally a table cell containing a time-stamp (this will have one or two Cumulus web tags) made up of a time and/or date.
 
*To change the label, simply edit the text. For example, you could change
<pre>
<td>Low&nbsp;Wind&nbsp;Chill</td>
</pre>
to
<pre>
<td>Greatest&nbsp;Wind&nbsp;Chill</td>
</pre>
 
*To show the value in different units, you would need to add some [[PHP|script]] to do the conversion. Scripts can be written in a number of languages. One possibility is JavaScript, that is parsed by the browser as it loads the code. For example, suppose your wind speeds are in mph and you wanted to show the equivalent in nautical miles per hour:
<pre>
<td id='wind'><#wgustYM>&nbsp;<#windunit></td>
<script>
var gust=1.150779*parseFloat(<#wgustYM>);
document.getElementById('wind').insertAdjacentHTML('beforeend'," (" + gust + " knots)");
</script>
</pre>
Note: You don't need to have the script code in the HTML immediently after the HTML element the script is updating, that was done here to make the example self-contained.
 
Another possible script language is PHP Hypertext Preprocessor. This is parsed by the web server to create HTML code that is forwarded to the browser, so the browser does not see PHP script. As PHP is a powerful language, it has a separate article [[PHP#Using_PHP_Hypertext_Pre-processor|here]].
 
*To change the way the time and/or date is shown, you add the format clause to each web tag you wish to alter as explained [[Webtags#Time.2FDate_.27format.27_Parameter|here]]. For example, you could change a 24 hour format time into an am/pm time:
<pre>
<td>at&nbsp;<#TwgustYM></td>
</pre>
to (Cumulus 1 only example)
<pre>
<td>at&nbsp;<#TwgustYM format=hh:nnampm></td>
</pre>
 
= Creating or Editing Templates in a Separate Folder =
5,838

edits

Navigation menu