Table of Contents

Document Templates

This article is a technical overview on the purpose and capabilities of Digital-Clay Document Templates. It is not a tutorial on how to build Templates.

Introduction

Document Templates are templates that are used in Digital-Clay to generate documents. The Template may contain static content, as well as instructions for generating dynamic Digital-Clay content which is only filled when the document is generated. In other words, the procedure is:

  1. A developer or administrator creates the Document Template typically using the Document Template Builder. This only needs to be done once.
  2. The Template is deployed or sent to any end-users that need it (see Sharing & Deploying Templates).
  3. The end-user generates a document from the Document Template as many times as necessary (see Generating Documents). Documents can be generated for different records, or using different dynamic filter values.


Some examples of documents that can be generated:


Document Templates are typically HTML files (other formats are also supported) that contain Digital-Clay 'tags' with instructions for adding dynamic information to a document. For example:

The document that is generated from the Document Template may be generated in the same format as the template (HTML, TXT, XML, etc), or it can be generated as a Word, Excel or MHTML document.

A Document Template can be edited either in an external editor (e.g. an HTML editor), or by using the Digital-Clay 'Document Template Builder', depending on whether you wish to add static or Digital-Clay content respectively. An existing file can also be converted into a Document Template using the Document Template Builder.


Template Files

Template Format

Document Templates, by default, are standard HTML files for all intents and purposes. This means that Document Templates:

This only applies to the Document Template format. When a document is generated from a Document Template, the user may choose to automatically convert it to MHTML, Word or Excel.

In addition to HTML as the Document Template format, other text-based formats are supported such as TXT, CSV, XML. For example, a CSV file can be created that contains only a Digital-Clay tag for creating a table of results with custom separators (see below). The rest of this article will refer to Document Templates as HTML templates because this is the format used in the vast majority of cases.


Document Template file-name extensions: A Document Template must contain a double file extension: 'stm', and the original file extension. For example: 'Report.stm.html', or: 'Output.stm.csv'.


Some examples of HTML content that may be included in Document Templates:


IMPORTANT: The HTML content must be in standard HTML format. This means that when editing Document Templates in MS Word, you must save it as “Web Page (Filtered)”, otherwise Word adds proprietary Microsoft-specific tags to the HTML file.

Digital-Clay Content

A Document Template typically contains a basic HTML skeleton and Digital-Clay fields with optional additional HTML content. The Digital-Clay fields are edited using the Document Template Builder, and the HTML content is edited using any HTML editor. The order with which this is done is not important. For example, you can:

Note that when you open an existing HTML file or Document Template in the Document Template Builder, it maintains the HTML content as is and only displays the Digital-Clay fields for editing.

Also note that HTML files must contain at last one Digital-Clay Tag in order for the HTML file to be recognized as a Document Template. This can be achieved by copying-pasting the tag into an existing document, or by opening and saving the document at least once in the Document Template Builder.


Using the Document Template Builder, Digital-Clay fields can be added to a Template either by:


All Digital-Clay query fields such as lists, analysis, graphs, charts, gauges and scorecards can be set to use dynamic filters. The user will then be asked for filter values before the document is generated.

For extra settings (e.g. dynamic filters, table settings, totals, groupings) related to Digital-Clay content inside Document Templates click on the Properties button in the Document Template Builder.

Digital-Clay Tags

All Digital-Clay content in a Document Template is contained in %Clay…% tags (and their corresponding data in the <ClayData></ClayData> section). These are not HTML tags and will therefore appear in all HTML editors as normal text so that they can be positioned and treated just like text.

An example of a merge field: “Dear %Clay Last Name%,”

A Digital-Clay tag/field may be used anywhere in HTML content, this includes:


Another proprietary tag used by Digital-Clay is the %StartClayHeader%…%EndClayHeader% set of tags. Anything contained within this set is treated as a Document Template header. This is relevant when a document is being generated on multiple items: The header will appear only once, or repeatedly before every item, depending on whether the user selected to start a New Page before each item or not.


HTML Styles

Styles can be applied to Digital-Clay content either by:

Template Folder

Document Templates are always stored on a hard drive as files (not in a database) where a Digital-Clay client can access them. This is also so that templates can be edited using any HTML editor, and also in order for the templates to work even while a client is offline.

The location of these templates must be defined so that Digital-Clay clients can scan the folder for templates when the user wants to generate a document.

For information on how to get the Document Templates into this folder, see Sharing & Deploying Templates.

Note that Digital-Clay also supports sub-folders under this root Template folder. I.e. Templates can be organized under sub-folders and then the user can select which sub-folder to scan for Templates before generating a document.

Linked Files

One disadvantage of using HTML files, is that external files such as images are stored often as local files. This means that when a Document Template is shared, all local files must also be copied along with the HTML file. Digital-Clay addresses this in version 9.0 by sharing Document Templates as 'template archives', or zip files. When a user sends or shares the Document Template from inside Digital-Clay, the internal procedure is completely transparent and works as follows:

  1. The HTML file is scanned for all links to external files.
  2. All files that are stored as local files only (not http links) are copied to a single subfolder along with the HTML file.
  3. A zip file is created that includes all of these files and this archive is sent instead of the HTML file.
  4. At the receiving end, the zip file is unzipped into the user's Template folder.


One exception is HTML frames. Digital-Clay does not currently support HTML frames since this involves several HTML files.

Note that this is only relevant to the Document Template itself. When a document is generated from a Document Template, the user may choose to automatically convert it to MHTML, Word or Excel all of which embed the external files inside a single document.

If the document is generated in HTML format, then:


Table Separators


Tables inside Document Templates are, by default, generated as HTML tables. This includes lists (browser queries), and analysis queries displayed as tables.

Using the 'Properties' button inside the Document Template Builder, this behaviour can be changed:

In addition, the table itself can be customized:



Using Templates

Template Topics

The most important concept in a Document Template is its topic. The topic is either 'General', or a table like 'User', or 'House'.

When the topic is 'General', this means that the Document Template is not generated based on specific records; it is not dependent on records and is generated without selecting any records first. This means that:

To help you decide which topic to choose, here are some examples:

Sharing & Deploying Templates

As explained above, Document Templates are stored locally per client. In order to share or send the Document Templates to other end-user machines, the following options are available:

Also see above regarding Linked Files.


Generating Documents

An end-user can generate a document from a Document Template using any of the following options:


Document on Multiple Items

When selecting multiple items to generate a document on, there are several options:


Note on grouping vs. selecting multiple items: Another option for displaying one table per item is via the Grouping setting. E.g. a list can be generated containing all Tasks and their assigned Users, and then it can be grouped by User, thus creating a separate table of Tasks per User. The differences between the two features are:


Other

See also Auto-Attaching Documents and E-Mails and Document Types.