eXtension Templates for PHP (XTP for short)
Starting everything - Rendering HTML to the browser
In order to make template engine running we need to complete few simple steps:
- Load page template (.phpx file)
- Send rendered HTML to client's browser
require_once('path_to_xtp.php');
$page = WebControlX::LoadControl('index.phpx');
if ($page) {
$html = $page->Render();
print $html;
}
else
print "Can't load page content!";
In this example we assumed that template for main page is contained in index.phpx template file. WebControlX::LoadControl will load that template (and all necessary subcomponents); and after that page's Render method will render HTML which will be sent to the browser.
This example makes lifecycle of page obvious (and of every other control) -- first, page is loaded, then its content is put into string variable, and then it is sent back to the browser. Method Render of WebControlX class serves purpose of getting entire content (HTML) of web component, including any embedded components.
| « Previous Logic controlling component - PHP | Next » Using control properties |
