Server Page Templates
Templates let you separate the logic from the interface. That way, designers can focus on the HTML and CSS code that defines your application visually, as well as images and other resources. Then, you can use components to add logic and live content to the application, on top of the template.
Since you can use a template file with several pages, the usage of template engines also favors code reuse, and makes it easy to apply style changes all over your application.
To use a template on a server page:
- Develop a template file. The syntax for the template files depends completely on the template engine you are going to use, so check out the available engines, decide which one you want to use, and learn how to define a template file with it.
- On the Page container:
- Set TemplateEngine to the template engine of your choice.
- Point TemplateFilename to the target template file.
The RPCL supports by default the following template engines:
- A powerful PHP template engine.
- Previously known as VCL, the RPCL template engine is an extension of the Smarty engine which includes RPCL-specific features.
Frequently Encountered Problems
Access is denied
When using templates with your applications, you might run into the following error:
- Application raised an exception class UnexpectedValueException with message 'RecursiveDirectoryIterator::__construct(<path>,<path>): Access is denied. (code: 5)'
This is usually caused by another application creating temporal content without read-access in your temporal directory.
To workaround this issue:
- Create a new folder in your temporal directory. For example: C:\Users\YourUsername\AppData\Local\Temp\HTML5Builder.
- In the RPCL folder, you will find a file named smartytemplate.inc.php. Open it.
- Locate the line with the code
$this->_smarty->compile_dir = $tmpfolder;, and append the new temporal subfolder to the
$tmpfoldervariable. For example:
$this->_smarty->compile_dir = $tmpfolder."/HTML5Builder";.
- Save the changes to the file.
Note: You might need to change the permissions of smartytemplate.inc.php to be able to modify it.