Customised templates: Difference between revisions

m
→‎Using PHP templates: added missing declarations!
m (→‎Using PHP Hypertext Pre-processor: Improved first sentence)
m (→‎Using PHP templates: added missing declarations!)
*The file still contains the HTML shown earlier, indeed it might be a simple edit of a standard cumulus template.
*It still contains Cumulus web tags, but as it is no longer a standard page, it has to be listed on the ''Files'' tab of the '''Internet''' screen within the 'Configuration' menu; the remote file name must have the extension ".php" so that the PHP processor will parse the file, before it is passed to the browser as a HTML page.
*The php script might be used for a decision more complicated than the [[Webtags_as_boolean_operators_in_HTML|boolean options]] that can be achieved just with standard HTML. For example, in the UK vehicle headlights must be used between half-an hour after sunset to half-an-hour before sunrise, so maybe you want to modify youra standard "todayTxxxxT.htm" page that becomesis currently processed into "todayxxxx.htm". so Change it becomesto be processed into "todayxxxx.php" instead and incorporatesincorporate 2 new chunks of code:
<code>
&lt;?php // start of PHP script setting new variables not available in Cumulus web tags
 
// setting PHP variables using web tags available in Cumulus (version 1.x.x)
// end of lighting up time (hours of darkness)
 
$latestDay = '<#metdate format=yyyy>'.'-'; # Year could be treated as integer converted to string, but easier to make it literal
 
$latestDay .= '<#metdate format=mm>'; # Read as literal so any leading zeros do not make it Octal integer
 
$latestDay .= '-'.'<#metdate format=dd>'; # Read as literal so any leading zeros do not make it Octal integer
 
$sunrise = "<#sunrise format=h:nn>"; # use format to remove any leading zero, so can not read it as Octal integer
 
$sunset = "<#sunset>";
 
// setting new PHP variables (not available in Cumulus web tags)
 
// end of lighting up time (hours of darkness)
 
$darkness_end = new DateTime($latestDay.' '.$sunrise); // sunrise
5,838

edits