To desambiguate I will call theme a template as a whole directory of files and template a separate php file that is used to render content.
The themes are located in the
./templates directory. The default
theme is Skela and it's based on the Skela
1080px grid system.
You can use and modify Skela which tends to be as agnostic as possible, so that it's easy to modify it with your own styles.
However, it's also easy to implement any of the html templates you can grab on the web, or create your own.
Templates are php files. For basic usage you need at least index.php. This file can include other files (like header.php, footer.php and aside.php ...). To include dynamic content, you simply echo object properties that are defined in the code or include other files.
<?php include("header.php"); ?> <div class="row"> <div class="content fourteen columns"> <?php echo $page->content; ?> </div> <aside class="four columns"> <?php include 'aside.php';?> </aside> </div> <?php include("footer.php"); ?>
The variables you include in templates are simple object properties you access as
$object->property. There are three objects available by default:
$widgets. Bellow is their description and a list
of properties they contain by default:
_config.phpfile, used for setting the content of the
<title>tag. You can use it also to set the main heading of the site or anywhere else.
<link rel="stylesheet" href="<?php echo $site->template_url; ?>/css/custom.css">It's defined by the
The easiest way to define custom variables is defining them in the
The variables defined this way are available in the
This is usefull to define things like footers, site slogans and in the case of multilingual
sites, it's the place to define common language strings, since there's a _config.php
file present in every language folder for the language in question. Example _config.php file
return [ "title" => "PHaiku", "slogan" => "brief and efficient", "copyright" => "(c) 2014 gresak.net", "more" => "More to comme ..." ];
You can also define variables in the object
$widgets by defining widgets,
or define them in your custom made handlers.
Objects that define variables are of type
\PHaiku\Data that extends
stdClass(). The extension uses a magic
method to return an empty string on non defined properties. For this reason, you don't
have to worry if your template has any undefined properties.
That's all there is to templates.
Feel free to comment or ask questions! Thanks!comments powered by Disqus