This article introduces variables and explains how to create them.
What are the variables?
Variables change what pages display in the front-end. Pages inherit variables and their values from parent folders. Producers can override values of inherited variables.
For example, consider the folder /archive with variable @archived_tag = "archived":
Then, consider the child page /archive/alpha-news-old and suppose it contains a module Archived-Articles with the field Tags to set the tags of the articles to list.
You can use the variable @archived_tag – that /archive/alpha-news-old inherits from its folder /archive – to value the field Tags:
Based on this configuration, the module Archived-Articles displays articles that have the tag archived.
Producers can change which tags to use to list old articles by only modifying the value of @archived_tag in /archive. The child pages of /archive change the list of the old articles they display accordingly.
See more information about variables in Presentation.
Where are the variables found?
Each folder and page displays tab Variables for users belonging to an authorization group with the EditVariables permission:
Create new variables
Note: Creating and modifying variables requires publishing the page to apply changes in the front-end.
To add a variable, select the + button in the bottom-right of the screen:
You can add three types of variables:
Key Value Data Item List Item
Define the variable by:
Variable name: The variable identifier, e.g., @archived_tag.
Value: The value of the variable. It's possible to define different values per language. For example, @archive_title can value Old news in English and Vieilles nouvelles in French.
Variables and their values are part of the page definition and determine the front-end business logic. For example, based on the @archive_title actual value, the front-end can change the UX it delivers to users.Type: Select how you want the Value to be validated when assigned to a layout or module property:
String: If Value doesn't need any validation.
Date: If Value must contain a date.
Number: If Value must contain a number.
Guid: If Value must contain a GUID (Global Unique Identifier).
Bool: If Value can be true or false.
Note: The Type field doesn't imply any validation on the Value field. Indeed, producers can value the Value field by referencing other variables whose value is unknown at design time.
Define the variable by:
Variable name: The variable identifier.
Path: The data path of the entity.
Entering the Path box, you'll get the list of the available paths:
Once you select the path, the EntityType field is auto-filled, even if you are free to change it:
Type: The entity type.
Define the variable by:
Variable name: The variable identifier.
Path: The data path of the entity.
Entering the Path box, you'll get the list of the available paths:
Once you select the path, the EntityType field is auto-filled, even if you are free to change it:Type: The type of the entities in the list.
URI variables
When the page name contains parameters, URI Variables are automatically listed in the URI Variables section, for example, /_a_big_fan_of_alpha/website/archive/{slug}.
URI variables can be used to value parameters of templates, layouts, and modules as the other types of variables. Instead, URI variables cannot be manually created — like the other variables — because they correspond to the parameters in the page name.
Sample values feed URI variables when previewing pages. Add sample values to make the page preview work. A warning icon highlights when sample values are missing.
By hovering over URI variables, the edit button displays.
By selecting the edit button, the edit popup page displays, which allows:
Adding sample values: They are comma-separated values the preview engine uses to preview the page.
Adding allowed values: They are comma-separated values the front-end uses to validate whether the page can be rendered.