template
From SkyPHP
Templates contain the code that is shared by different pages. Every page uses the template class to include a template.
Contents |
Commonly used templates
- website
- intranet
- mobile
Template files
Templates are stored in the /templates folder and consist of php, css, js and images. For example, the website template has the following files:
- /templates/website/website.php
- /templates/website/website.css
- /templates/website/website.js
- /templates/website/images/
The 'global' template
The global template is in the skyphp codebase and contains all the important stuff that EVERY webpage needs. For example, it contains the HTML, HEAD, and BODY tags among other things.
Both the website and intranet templates include the global template.
Functions
- template::inc( string $template_name, string $template_area ) -- include a portion of a template
- template::breadcrumb() -- displays the breadcrumb of pages
Breadcrumb
see page settings
Examples
A page that uses the 'website' template
<?
$title = 'Page Title';
template::inc('website','top');
?>
<h1><?=$title?></h1>
<div>The content of this page goes here.</div>
<?
template::inc('website','bottom');
?>
Example website template php file
/templates/website/website.php
<?
if ( $template_area == 'top' ): # display top portion of template
template::inc('global','top');
?>
<!-- website template top area -->
<div id="header">
[website logo here]
</div>
<div>
<?
elseif ( $template_area == 'bottom' ): # display bottom portion of template
?>
</div>
<!-- website template bottom area -->
<div>
© <?=date('Y')?>
| <a href="/terms-of-service">Terms of service</a>
| <a href="/privacy-policy">Privacy policy</a>
| <a href="/contact-us">Contact us</a>
</div>
<?
template::inc('global','bottom');
endif;
?>
Note
DO NOT PUT SUBFOLDERS IN THE TEMPLATE FOLDER
