Customised templates: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
665 bytes added ,  09:14, 19 February 2015
m
→‎Using PHP templates: added missing declarations!
m (→‎Using PHP Hypertext Pre-processor: Improved first sentence)
m (→‎Using PHP templates: added missing declarations!)
Line 329: Line 329:
*The file still contains the HTML shown earlier, indeed it might be a simple edit of a standard cumulus template.
*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.
*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 your "todayT.htm" page that becomes "today.htm" so it becomes "today.php" instead and incorporates 2 new chunks of code:
*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 a standard "xxxxT.htm" page that is currently processed into "xxxx.htm".  Change it to be processed into "xxxx.php" instead and incorporate 2 new chunks of code:
<code>
<code>
&lt;?php // start of PHP script setting new variables not available in Cumulus web tags
&lt;?php // start of PHP script


// end of lighting up time (hours of darkness)
    // setting PHP variables using web tags available in Cumulus (version 1.x.x)
 
                $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
$darkness_end = new DateTime($latestDay.' '.$sunrise); // sunrise
5,838

edits

Navigation menu