view.myname.php
, where myname
is the actual name of your view.You place your view files in a folder namedNOTE: The view can be an HTML file like
view.myname.html
.
views
in your app folder. This is where EXC would look for them by default.<!doctype html> <html> <head> <title>{{title}}</title> </head> <body class='layout'> Hello {{username}}...<br> {{contents}} </body> </html>You can add value placeholders that you replace from PHP. For example a placeholder for a "username" is defined as
{{username}}
.{{username}}
, {{contents}}
and {{title}}
.set($html)
method:<?php $username = "supercoolcat99"; $view->username->set($username);You can append to a placeholder with the
write($html)
method:
<?php $view->contents->write($someHTML); $view->contents->write($moreHTML);### Beyond placeholders ### {#bplaceholders}
$location = 'RUM'; \exc\ui\views\view::constantSetValue("location", $location);In your view file a constant placeholder is available as:
{{@location}}Special framework values are available as @CONTANTS in your view file.
NAME | DESCRIPTION |
---|---|
@URL_BASE | URL path of your app. |
@URL_CONTROLLER_DIRECTORY | URL path to the folder with current controller. |
@URL_CONTROLLER | URL pointing to the current controller. |
@BASE | Path of your app. |
@CONTROLLER_DIRECTORY | Path to the folder with current controller. |
{{#view record_header}}### file directive ## {#dirfile} Use the #file directive to include a file:
{{#file /absolute/path/file.js}}You can use exc's special url protocols with #file, for example
asset://
, file://
, app://
, and exc://
:
{{#file asset://header.html}}Similar to the file #file directive you have the short hands #script and #style directives. Each will place the contents of the file in a corresponding
<script>
or <style>
tag.
{{#script asset://js/myscript.js}}### if directive ## {#dirif} The #if directive will include its contents when the value of a variable evaluates to true.
{{#if ind_new_account}} <b>Welcome to EXC...</b> {{end if ind_new_account}}### inherits directive ## {#dirinherits} Use the #inherits directive to make a view that is based on another template. This is useful to avoid duplicating content. An inherits directive should be the first line of your view template. Lets see an example:
{{#inherits default {{body}} }}The first argument of this directive is the name of a view file that will be used as template. In this example is
default
for the file view.default.php
.{{body}}
.$options['views.paths']
. Set $options['views.paths']
to a string with the path to a folder with your views.$options['views.paths'] = '../employee_common/views/';
You can also use an array with multiple paths as needed:NOTE: A path can be an absolute path or relative to your application.
<?php $options['views.paths'] = [ '../employee_common/views/', '/Library/WebServer/Documents/examples/shared/views/', ];