Basic Syntax

Parent Previous Next

(TBD)

About the Smarty Template Engine

Heurist Reports are powered by the Smarty Template Engine.

Some basic facts about Smarty Syntax are provided below. Full Smarty Documentation can be found here:

Any templates you create in the Report View adhere to the same syntax and structure of Smarty templates; all standard Smarty template plugins and modifiers can be used, and your templates is parsed, cached, and displayed by the latest release of Smarty.

Note. Smarty is open source software, developed by the developers of the PHP programming language. Heurist uses the latest release of its software. This version is optimized for web servers that use PHP5.

The following is a sample of template code. It is used to display a list of the five latest news headlines on a news site:

<ul>

{content type="headlines" var="headline" limit="5" sort="date" sort_dir="desc"}

<li>

 <a href="{$headline.link}">{$headline.headline}</a> ({$headline.date|date_format: "%m %d, %Y"})

</li>

{/content}

</ul>

You can get started developing Smarty-based templates with a modicum of Smarty knowledge. As you learn more about Smarty you can develop more sophisticated templates.

Note. Smarty conditional functions, variable and loops can be selected from the right-hand pane when completing the report template code, or can be entered manually.

Smarty works by allowing you to incorporate various variables and plugins into the HTML syntax of your reports. This gives you complete control over what is displayed to the end user.

Smarty files are basic HTML files that can be edited in any text editor; you do not need to install anything extra to use Smarty. You therefore have complete control over the HTML displayed to the end user.

You can link Smarty files to JavaScript, CSS stylesheets, and other files.

Plugins

Template plugins provide advanced template functionality. Template plugins include:

Plugins are always loaded on demand. Only the specific modifiers, functions, resources, etc invoked in the templates scripts will be loaded. Moreover, each plugin is loaded only once, even if you have several different instances of Smarty running within the same request.

Main records

The foreach statements enclose a loop which outputs information for each record in the query result. Fields can be inserted with the insert links next to each field. Use the if links to insert tests based on the value of a field (eg. to only output text if a field is set).

Subrecords

Further loops can be inserted to output multiple sub-records within the main record loop, using the loop link after the subrecord name. Fields within sub records can be inserted with either the in or out links; use the in link to insert a field within a loop, use the out link to insert a field outside a loop.

Created with the Personal Edition of HelpNDoc: Easily create Help documents