Skip to main content

Application::fetchPage

Return compiled template with declared controller and template variables into a string

Description

public string Application::fetchPage( string $template )

Returns the Application::displayTemplate result into string after including the assigned variables in controller class that can be use in template file.

Arguments

NameData typeDefaultRemarks
$templatestringTemplate file name

Appended arguments when compiling

Example

code/application/Foo.php
// URI: http://example.com/foo/bar/?get=param

<?php

class Foo extends Application
{
function bar(){
$this->page['baz'] = 'qux';
$content = $this->fetchPage( 'foo/bar' );
echo $content;
}
}
code/template/foo/bar.tpl
Baz params : {{ $page.baz }}
$_GET[get] params : {{ $in.get }}
Controller name : {{ $classsName }}
Output
Baz params : qux
$_GET[get] params : param
Controller name : foo

After assigning arguments for template, run the Application::fetchTemplate method.