Creating a new Template Variable¶
Template Variables can be injected to TypoTonic fluid templates. You can select them in the Records-Plugin and later in many more plugins. The Template Variables can help you improve functionality of your displayed data by using them as filters, search, sortings or as modifiers. With help of the dynamic data, that is processed, when variables are injected, it is possible to add different functions to your view instead of just displaying data.
Determines the type of the value. It can be dynamic or fixed. Please see the following options with their description.
|Fixed Value||A fixed text value|
|TypoScript Value||Parsed TypoScript value|
|GET Variable||Value from the GET Parameters of the page|
|POST Variable||Value from the POST Parameters of the page|
|Database Value||Database Result Value from a given query|
|Frontend User||The current frontend user|
|Server Variable||A variable from the SERVER ($_SERVER)|
|User Session Variable||Extracts a variable from the frontend user session|
|Page||Adds the complete page information of the selected page to the variable|
|UserFunc||Calls the entered user function and puts the output to the variable|
|Backend User||Adds the current logged in backend user to the frontend
template. If no user is logged in, it contains
|Language Id||Adds the current language id to the template|
|TypoTonic Session Service Container||Adds the TypoTonic Session Service Container to the template, which contains all the filters, searches and more|
The variable name that can be used in the fluid template.
- Inject dynamic values like the current date
- Inject back- or list page Ids to link to other pages without hardcoding ids
- Add custom PHP Script Values to the output by using TypoScript and USERFUNC
- Inject the current record on a site when using multiple plugins
- Provide different content by using conditions for variables
- Use variables to combine with filters of the records plugin
GET/POST Variables have a different set of options for defining specific data, when variables are injected to the view.
The variable can be set for a specific type, so you can prevent injection of malicious code.
Same like Type Definition, it is possible to set a regular expression to prevent unwanted injections.
Variable values can be predefined, so it is now possible to change the values to other content than defined.
The Value Switch is a highly customizable way to change the value of the variable, before it is injected into the template. With the Value Switch, the data can be changed with the use of fluid. Each Value Switch has a condition (also written in fluid), which activates the switch, when the condition matches.
See the following example for a switch to create a sort order link with the opposite order, as given in the parameters: