Concept

When using HTML_Template_PHPLIB to generate HTML or other code from templates, you do the following steps:

  1. Create template class instance

  2. Load template file

  3. Define blocks

  4. Set variables, parse blocks

  5. Finish and output

Variables are placeholders in your HTML code that can be replaced with dynamic values provided from database or calculated in your code. An example for a variable is {CODE_AUTHOR}: You enclose the variable name in curly braces. The name of the variable may contain any characters, except spaces, tabs and newlines.

Blocks surround certain pieces of HTML code and can be re-used, e.g. a <tr>row in a table. Blocks are defined by using HTML comments, containing BEGIN or END, and the block name. Example:

<table>
 <caption>Authors</caption>
 <thead>
  <tr><th>Name</th><th>Email</th></tr>
 </thead>
 <tbody>
<!-- BEGIN authorline -->
  <tr><td>{AUTHOR_NAME}</td><td>{AUTHOR_EMAIL}</td></tr>
<!-- END authorline -->
 </tbody>
</table>
HTML_Template_PHPLIB (Previous) Simple example (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.