Create Report Template
You can create custom reports templates using the Smarty Report Engine. These templates then become available in the Report toolbar to be run against any result-set.
About 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. Any templates you create via 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 are parsed, cached, and displayed by the latest release of Smarty.
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.
Note. Reports work with record type and fields codes rather than names; this prevents formats being broken if field names are edited.
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. For example, the following snippet of code 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>
(See Smarty Syntax for an overview of the smarty syntax, including worked examples. For complete Smarty Documentation go to the Smarty Site itself.)
Create a Template 
To create a new report template, ensure you have run a search in order to have a data subset to test your template. Go to Report View and from the Report toolbar, click New .
Enter a suitable template name at the prompt. The Template Editor screen displays:
Use this screen to define your report template using HTML and the Smarty syntax (see Smarty Syntax).
A basic example template is created by default, which you can then use as a starting point or remove and start from scratch. The basic template consists of:
- Some guidance as comments, enclosed in {* *}. Remove or add comments as you wish.
- A records loop which should enclose everything you want reproduced for each record.
- Some example fields within the loop (to create a simple report).
Enter the report code in the Template pane. You can either:
- Enter the code manually.
- Use the Actions Pane on the right to quickly enter some basic actions (conditional functions, variable and loops) based on the fields and terms available for your record query. (See Actions Pane below).
When complete, click Save As to save your report structure. This will now be made available for selection when you choose to print or publish the report. Click Close Editor when finished.
Actions Pane
The Actions Pane provides a records/fields tree of your database structure that assists you in creating a simple template (with loops, fields & functions) to produce neatly formatted lists in text (e.g. CSV, and HTML formats, including images, video and so forth).
More complex formats can use all the power of the Smarty template language, including PHP functions (standard or user-defined) directly in the template.
To use the Actions pane, insert the cursor in the code where you wish to insert the syntax. Press Enter to add extra lines if required. Select the appropriate record type. For each code string, first position the cursor in the appropriate location in the report, then select the appropriate function from the actions pane. In the following example, the user has created an If statement wrapper, and can now enter variable code between the If statements as required.
Note. Untyped pointers do not appear on this list; instead a dialog will assist you.
To enter field variable details, for an IF Statement or Repeat Loop, click on the insert option for the relevant field. This displays the Insert dialog:
Note. You can output the leaf term alone or the leaf term with its hierarchy (where terms are hierarchical).
These have the following elements which you can insert into the code:
Insert Fields Value |
Inserts the value of the selected field. From the dropdown you can specify how the field information is displayed.
|
Test Value (IF) |
Click this button to insert a test value for the loop. |
Preview Results
To preview the results of your template, click TEST. The report output is shown in the bottom Pane (only a subset of the data is shown, for efficiency).
The two dropdowns let you set the the scope of the query (for the test only, not the published report), and to troubleshoot the code (show warnings, show errors etc.):
The test results are updated immediately.
Edit, Copy & Delete Template
To edit a template, go to Report View, select a report from the Select Template dropdown. Click Edit . The Template screen Displays. Edit the template as required (see above). When complete, click Save, or Save as to create (copy) a new report from an existing report. Click Close Editor when finished.
To delete a template, select a report from the Select Template dropdown and click Delete .
Warning. If you delete the report template at the next step you cannot retrieve the report again.
Click OK at the prompt to delete the report.
Created with the Personal Edition of HelpNDoc: Easily create EPub books