Cumulus template file: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
m
=Template files you add=
 
As explained on this page, template file can generate a variety of file types. People writing their own templates can use any file extension (some popular choices are "tmpl" or "cum" to indicate they are Cumulus templates). To ensure that the template files and generated web pages cannot be confused, Steve Loft realised the "T" notation used by the provided templates may not be part of the name youused chooseby third parties for their templates, hence he designed Cumulus such that (for a non-standard name) the generated file will have "tmp" added to the end of the template name you selected, just to remind you of its temporary existanceexistence (until the source template is processed again). That "tmp" is removed when the final web page is stored on your web server.
The page dealing with the customisation of web templates is [[Customised templates]], and it includes a diagram that explains how file names are affected by your choices in some of the settings for file transfer.
 
People writing their own templates can use any file extension (some popular choices are "tmpl" or "cum" to indicate they are Cumulus templates). To ensure that the template files and generated web pages cannot be confused, Steve Loft realised the "T" notation used by the provided templates may not be part of the name you choose, hence the generated file will have "tmp" added to the end of the template name you selected, just to remind you of its temporary existance until the source template is processed again. That "tmp" is removed when the final web page is stored on your web server.
 
''Note by Steve Loft: When you put a tag into your template, be careful that whatever program you are using to develop your web pages doesn't change the angle brackets to slightly different symbols -- this is a common cause of failure!'' There are a number of editing tools that are '''designed for editing programming code''' and you should use one of those (e.g. Notepad++, Brackets, NoteTab Light, HTML kit, amongst many others), ''rather than a tool designed for web page design editing'' (e.g. Dreamweaver, word press, amongst others).
 
There are a number of editing tools that are '''designed for editing programming code''' and you should use one of those (e.g. Notepad++, Brackets, NoteTab Light, HTML kit, amongst many others), ''rather than a tool designed for web page design editing'' (e.g. Dreamweaver, word press, amongst others).
 
=== Using web tags in templates for creating HTML pages ===
 
TheIf pageyou dealingwant withyour thetemplate customisationfile ofto generate a web templatespage, then this is discussed fully on the [[Customised templates]] page, andwhere itthere includesis a diagram that explains how file names are affected by your choices in some of the settings for file transfer.
You can include special markers in your template file that are called web tags; during processing Cumulus will replace them with the actual values.
 
Here I just remind you that [[Webtags|Cumulus web tags]] are the special markers in your template file; during processing of that template file, Cumulus will replace them with the actual values, in the web page it creates. However, this is just one of many ways to build your own website with Hyper-Text Manipulation Language file with your layout, including static text and perhaps graphics, calling a Cascading Style sheet to define the look. Creating a template with all the content needed for a web page means you are uploading large files (with a significant proportion of their content never changing) every time you want new data on your web site, so the next section describes an alternative way to use a template file to get just the data to your web server.
Typically you would use this to build your own website by having an HTML template file with your layout, static text and graphics.
 
=== Using web tags in scripts ===
 
As mentioned in previous section, it is inefficient to create a template file where the majority of the content is not web tags and so never changes. JavaScript Object Notation (JSON) files are probably the most efficient way for template files to include just web tags, with minimal structure around them. (In fact MX uses this approach).
*You can also use the tags within script, this might be a PHP script, or JavaScript either embedded in HTML, or in external files, to transfer the values (or the result of calculations based on those values) to your web server for further processing.
 
*As JavaScript can not understand a real number that has the integer and decimal parts separated by a comma, but your computer may be set to use that representation in standard tags, there are special versions of many tags to use in script - see [[#No_Commas|tags with commas removed]] section.
If your JavaScript is less structured, then a .js script template can perform arithmetic, and/or validation, on web tags. This gives you more flexibility about how information appears on your web page, and it can support graphical ways of presenting data. JavaScript files can be called from a web page when it is viewed in a browser; consequently, your HTML file can be a static file on your web server, and call a JavaScript file that Cumulus has generated and uploaded, and that script can amend the contents of table cells in your HTML to display the latest data. A variant is AJAX, where a timer allows a fresh JavaScript file to be uploaded (without reloading the web page) and thus refresh the table cell contents; this is discussed elsewhere on more technical pages of this wiki (see [[:Category:WebTips]]).
*As JavaScript can not understand a real number that has the integer and decimal parts separated by a comma, but your computer may be set to use that representation in standard tags, there are special versions of many tags to use in script - see [[Webtags#No_Commas|tags with commas removed]] section.
*JavaScript is available in every modern browser (Microsoft's Internet Explorer initially used a different language '''jScript'''), but actually it is hard to get right. A human being recognises something as a number or text or operation. Programmers writing in JavaScript can use Objects, but you need to be skilled to do that. Without Objects, it is easy to write code that gets text and numbers confused; for example you can have two variables ('''door1''' and '''door2''') defining width of two adjacent doors and want total opening size in variable '''Opening'''. The code <tt>Opening = door1 + door2;</tt> might return the correct number if it recognises these are numbers (because they contain a decimal point), or it might treat them as text (especially if they are integers) and just concatenate the text! See bullet point below where "parseInt" is used to make JavaScript recognise integers as numbers.
 
PHP Hypertext Preprocessor (PHP) is another script language, it is parsed on the web server and so the browser only sees what is generated by the PHP script, not the actual script. PHP can do a lot, so it takes some time to learn, but it is very simple in concept, and you should find writing simple scripts is surprisingly easy once you master the syntax. There are many guides to writing PHP online, and you may find the notes on [[PHP]] page helpful in a Cumulus context.
 
*Note that if a PHP or JavaScript file contains any Cumulus web tags then you must [[Customised_templates#What_to_select_on_the_.27Files.27_tab_of_the_Internet_Settings_screen_within_the_.27Configuration.27_menu|ask Cumulus to process]] the script file.
*JavaScript processing code can be embedded in a template that is already being processed into HTML. (This technique has been used in the standard 'monthlyrecordT.htm' template).
*Alternatively embed a bit of JavaScript assignment code in HTML, that is already been processed, to convert the tags to a collection of string variables and use those variable names in any external script called from the HTML file. (This technique has been used in the standard 'gaugesT.htm' template in the legacy Cumulus 1 software).
*To use the value from a tag as an integer in JavaScript assigning code you need to use a
<pre>integer_variable_name=parseInt(string_variable_name,10)</pre> type conversion
 
In the web tag to PHP variable scripts, I have posted, see [[Php_webtags#Minimised_Upload_size]], I have tried to introduce better consistency in the PHP variable names, so "T" is added as a suffix to all "today" variables for example. Some other script authors try to match the inconsistent web tag names, so their script variable names are also inconsistent.
 
 
 
=Cumulus MX=
5,838

edits

Navigation menu