Application::displayPage
Display a page with the standard template variables and end the response
Description
public void Application::displayPage( string $template )
Renders the template with Application::fetchPage (so $page, $site, $in … are available), outputs the page and ends the response (see Ending a response). Code after displayPage() does not run.
This is the method to use for every page.
Arguments
| Name | Data type | Default | Remarks |
|---|---|---|---|
| $template | string | Template name relative to the template root, without .tpl (news/detail) |
Example
htdocs/_fegg/site/src/Controller/News.php
<?php
namespace Site\Controller;
defined('FEGG_CORE_DIR') || exit;
class News extends Controller
{
public function detail($id = '')
{
$this->page['title'] = 'Hello';
$this->displayPage('news/detail');
}
}
htdocs/_fegg/site/template/main/tpl/news/detail.tpl
<h1>{{ $page.title }}</h1>
Output
<h1>Hello</h1>
Errors
A missing template throws Fegg\Template\TemplateException (see Lint and errors).