-
Notifications
You must be signed in to change notification settings - Fork 34
TEMPLATES
Daniel Spors edited this page Nov 2, 2020
·
3 revisions
The scavix-wdf does not contain a dedicated templating engine. You may include your own or (as we do) just use PHP inline syntax. In fact we astracted UI in a MVC manner, so that *.tpl.php files next to *.class.php files are detected and loade automatically when components are rendered.
Templates follow a component based concept, so each template should be usable when assigned the correct data (mvc!). Htmlpage are just a special form of template, so using this is really simple:
// home.class.php
class Home extends HtmlPage
{
function Init()
{
$this->append("<h1>Hello World!</h1>")
}
}
This creates and renders a HTML 5 valid output with just the H1 added to the BODY. Of course you will get more complex :)
Here's how to create a top-navigation:
// topnav.tpl.php
<div class="topnav">
<? foreach( $navitems as $item ): ?>
<a href="<?=$item['href']?>"><?=$item['label']?></a>
<? endforeach; ?>
</div>
// home.class.php
class Home extends HtmlPage
{
function Init()
{
$navitems = [['href'=>buildQuery('home'),'label'=>'Home']];
Template::Make('topnav')->set('navitems',$navitems)->appendTo($this);
}
}