Text
Introduction
The text widget displays a text which can optionally contain parameters. A parameter can be an attribute of a context object or an expression which also has access to the surrounding context objects and their attributes. When used with parameters, every parameter placeholder in the text (which may appear as {0}, {1}, or {2} for example) is replaced with the value of its corresponding attribute or expression.
For example, if you want to build a page that shows some detailed information about books, you can configure a data grid to retrieve the whole list of Book objects from the database. Then, you can place a text widget inside a data view that is configured to listen to this data grid (for more information, see Listen to Widget Source). Finally, you can add parameters for your text widget to display information about the selected book from the data grid.
Properties Pane
The properties pane is divided into two major sections by a toggle at the top of the pane: Properties and Styling. Text properties consist of the following sections:
Properties:
Styling:
Properties
General Section
Caption
Caption defines the text that will be shown. It supports dynamic text using templating. The final text is determined by the given Template, Parameters, and Fallback Text, which can be found in the 'Edit Caption' dialog box. The dialog box can be opened in two ways:
- From the properties sidebar: double-click the property (for example, "Caption") or click the "more" ellipsis (...)
- From the widget properties dialog box: click the Edit button next to the property's textbox
Parameters
Template
The Caption can be made dynamic by placing placeholders in the Template. Placeholders must follow the format {i}, where i is the Index of a specific parameter from the list of parameters. Parameters can be referenced multiple times, and can be referenced out of order.
Parameters
Parameters define what data is inserted into the template and how it is formatted. Parameters can refer to object attributes or expressions. Editing parameters is done in the 'Edit Caption' dialog box.
Parameters have the following settings:
- Index – an identification number of a parameter
- Value – an attribute or an expression value to be displayed
- Format – a format in which the value will be displayed (only for attributes)
Adding New Parameters
To be able to use parameters, the Text widget must be in the context of an entity such as a Data widget, Snippet parameter, or Page parameter. To use parameters, do the following:
-
Open the properties for the Text widget.
-
Click the Edit ... button of the PROPERTY_NAME to open its dialog box.
-
In the Parameters section, click New:
-
In the Edit Template Parameter dialog box, click Select, choose an attribute, and confirm your choice.
-
Edit the template and add a placeholder that matches the index of your parameter (for example
{1}).
In the example below, the placeholder {1} corresponds to the Title attribute, {2} to NrOfPages, and {3} to DatePublished:
Performing Other Actions on Parameters
In addition to adding new parameters, you can perform the following actions on parameters:
- Delete – to delete a parameter click Delete or press Delete on your keyboard
- Edit – double-click a parameter to edit it or click Edit
- Move up – to move a parameter up in the list of parameters and also to change its index, click Move up
- Move down – to move a parameter down in the list of parameters and also to change its index, click Move down
Fallback Text
The fallback text is shown when the datasource of the Parameters is empty or unavailable.
Empty attributes used as parameters do not cause the fallback text to be shown. Instead the template is rendered as normal and the placeholders for the empty parameters are substituted by empty strings.
For example: The template Hello, {1}! with the fallback text "Nobody to greet." would get rendered as follows:
| Scenario | Rendered text |
|---|---|
| Filled attribute | "Hello, World!" |
| Empty attribute | "Hello, !" |
| Missing object | "Nobody to greet." |
Render Mode
The render mode determines how the text will be displayed.
| Value | Description |
|---|---|
| Text (default) | The text will be rendered inline with the previous/next texts on a page (<span> tag in HTML). |
| Paragraph | The text will be rendered as a separate paragraph (<p> tag in HTML). |
| Heading 1 - Heading 6 | The text will be rendered as a selected heading (for example, <h1> tag in HTML). Heading 1 is the largest type of heading, Heading 6 is the smallest one. |
Visibility Section
Visibility determines whether a widget is displayed to the end-user as part of the page.
For more information on properties of this section, see the Visibility Section section in Properties Common in the Page Editor.