Dynamically truncating the content of a field

Introduction

When designing a template, one requirement for a field could be to show it in a limited space in the design area, for example in a table cell with a fixed width. In this case, you might need to truncate the data displayed.

 

How to

In the following article, we will show the steps required to truncate a field in order to fit the space in a table cell.

  • Create a table with 10 columns and 2 rows(or create a table with one column and a fixed width);
  • Insert a field in one of the cells;

  • If we wish to only display the the first four characters in the rendered document, we will need to use the substring() function, where the first argument is the text we wish to truncate, number1 and number2 are the positions of the first and last characters in the field's content;

substring(string, number1, number2?)

  • Double click on the field you wish to truncate;
  • In the textbox, use the substring() function to extract the first 4 characters;

substring(/ns:catalog/ns:cd/@title, 1, 4) 

The rendered document will display only the first four characters from the text contained in the field.

To read more about XPath functions, click here.

Have more questions? Submit a request

Comments

Powered by Zendesk