How to insert information dynamically into a template?

Tabla de contenidos

Athento allows, in addition to inserting field values into templates, defining custom tags in Athento templates to print text or images. You can also condition the printing of these tags using smart rules. For example, in a contract template, you could include a clause only if the value of a field is X.

Step 1: Create a custom tag

To create custom tags, go to the Templates section of the form you are working with.

Enter the template by clicking on its name.

Go to the custom tags tab Custom tags.

Then, use the Add button to create a new tag.

Athento will ask you for a name for the new tag.

Click Create and the tag will be available to insert into your template. You will also be able to access the created tags from the template's Settings tab, below the field tags.

Custom tags work the same way as field tags: you must insert them in the template between {{}} (double curly braces).

Step 2: Define when the tag is inserted and its content

In the Custom tags tab, to the right of the created tag, you will see the options to add resources and conditions.

The resources are the contents (text or image) that will be printed in the template. The conditions are the rules that determine whether or not a resource is inserted.

For each tag, you must create at least one Resource-Condition pair so that the tag can insert a value in the template.

The same tag can insert different values, depending on whether one condition or another is met.

If, on the contrary, you want the tag to always insert the same value, create the Resource-Condition pair by adding the resource and leaving the condition undefined.

Click the Add button to define your first condition. Athento will ask you for a description; this will be useful when you have several Resource-Condition pairs for the same tag.

Tag content (resource)

If you don't have any resource created yet, click Add resource to create it.

To create a new resource, provide a name and a type:

  • Text type: text string that will be inserted into the document generated by the template.
  • Image type: image (.jpg, .jpeg or .png formats) that will be inserted into the document generated by the template. You must upload the image with the specific dimensions required for its use.

Once the type is selected, you will be able to enter its content.

In the example, we want the Contact method tag to have the value "Contact center" when it is printed in the template.

Click create resource and then select it from the drop-down. Finish by clicking Create.

Rule to insert the resource (condition)

If your tag will always print the same resource, it is not necessary to define a condition. However, if in some cases the Contact method tag must insert Contact Center and in others you want it to insert the value email, you will need to add conditions. To do so, use the Add condition button.

You can use the values of your fields so Athento dynamically determines what content it should print in the template. In the example screenshot, the resource is conditioned on the value of a field being "Athento Standard".

Reuse resources

From the Resources tab you can view, edit, delete and create the resources you will use in your tags. These resources are shared among all the form's templates, so you can reuse them in other templates different from the one you are configuring. Outside this form you will not be able to use the resources that have been defined.

Be careful when editing or deleting resources, as the changes will affect all templates that use them.

Step 3: Insert the custom tag in the template

Once the resources and custom tags have been created, you will be able to copy these tags into the template you are working on.

Custom tags work the same way as field tags: you must insert them in the template between {{}} (double curly braces). You can also click in the search box and select the custom tag; Athento will display it in the corresponding format:

When the tag is included in the template, when generating the new document the resource configured for that custom tag will be displayed.