Templates are included from the controllers via the display object, and are used to to build the pages. Each site has its own set of templates located in phork/sites/[sitetype]/templates/ and named in lowercase with the extension .phtml.

Templates shouldn't actually do any heavy lifting; any data used to build the template should be passed to it, and not retrieved by the template itself.

If a template is included from CoreController the displayNode() method should be used. If a template is included from another template the includeTemplateFile() method should be used.

Multiple Themes

It's simple to set up your site to use multiple themes. This is useful if you want to give your viewers some theming options, or if you want to redesign your site without interfering with the current theme. The following example shows one way to do it. This will look for an overriding template in the custom theme directory, and if that doesn't exist will fall back to a shared template. This assumes a Theme config variable was defined in site.config.php.

Example (from the controller)

public function __construct() {

    $this->assignPageVar('strTheme', $strTheme = AppConfig::get('Theme'));
    $this->strThemeDir = ($strTheme ? "themes/{$strTheme}/" : '');
    $this->strThemeCssDir = '/css/' . $this->strThemeDir;
    $this->strThemeJsDir = '/js/' . $this->strThemeDir;

protected function getTemplatePath($strTemplate) {
    if ($this->strThemeDir && file_exists($strThemeTemplateDir = $this->strTemplateDir . $this->strThemeDir . $strTemplate . '.phtml')) {
        return $strThemeTemplateDir;
    } else {
        return $this->strTemplateDir . $strTemplate . '.phtml';

protected function displayFoo() {
    $this->assignPageVar('arrStylesheets', array(
        AppConfig::get('CssUrl') . $this->strThemeCssDir . 'foo.css'

    $this->assignPageVar('arrJavascript', array(
        AppConfig::get('JsUrl') . $this->strThemeJsDir . 'foo.js',
        AppConfig::get('JsUrl') . $this->strThemeJsDir . 'foobar.js'

    $this->displayNode('content', $this->getTemplatePath('example/foo'));