Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics

PHPRunner templates

Scroll Prev Next More


PHPRunner uses the built-in template language. PHPRunner templates cleanly separate your presentation layer (HTML, CSS, etc.) from the application code. The main idea is to simplify visual templates by moving all logic and JavaScript to PHP files.

Template language reference

all template tags are enclosed within delimiters { and }. All content outside delimiters is displayed as static HTML.

template variables start with the dollar $ sign. They may contain numbers, letters, and underscores.




The string {BEGIN block_name} ... {END block_name} is used to define the block section (loops, condition statements).


assign ($name, $val) 

is used to assign the value $val to the variable $name.

Working with the templates

Here is a basic example of how templates work. Add the following code to the Before display event:


$xt->assign('name', 'george smith');
$xt->assign('address', '45th & Harris');


The template file contains the output with template tags that PHPRunner replaces with assigned content.


Example 1. Changing 'Nothing to see' message


By default PHPRunner displays 'Nothing to see. Run some search.' message when search returns no data. If you need to change this message to something custom, you can add the following code to BeforeDisplay event of the List page:


$xt->assign('message', 'my message');



Template file


<title>User Info</title>
User Information:<p>
Name: {$name}<br>
Address: {$address}<br>




<title>User Info</title>
User Information:<p>
Name: george smith<br>
Address: 45th & Harris<br>

Changing a button label dynamically

Here is how you can change a custom button label dynamically.


1. Insert a Custom Button into one of the pages using Page Designer. Use the following as button label:




2. Use the following code in the BeforeDisplay event of the page in question:


$xt->assign("button_label", "Edit Customer");

{BEGIN} ... {END} blocks

The template file contains a set of code sections wrapped by {BEGIN ...} and {END ...}.


Template file


{BEGIN Model_fieldblock}
<tr><td class=shade width=150>Model</td><td width=250>
{END Model_fieldblock}


Use the following code in the Before display event:




When you use true, the HTML code between {BEGIN ...} and {END ...} appears in the output.




When you use false, the HTML code between {BEGIN ...} and {END ...} is hidden.

See also:

About templates

Template files processing rules (Files.txt)

Template language

Page Designer: Working with page elements


Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software