Get and Set
Set tags are useful for remembering a value to use later, or in multiple places.
This is commonly called a "variable", which has a unique name and holds a reference to a value.
Set tag by giving it a name where to save the value.
In the example below, the current post ID is stored in a variable called
<Set name=current_id> <Field id /> </Set>
Get tag with a variable name to get the value.
<Get name=current_id />
In addition to regular variables, there are other variable types with special behavior.
- Path -
- URL -
- Route -
- List -
- Map -
- Loop -
- Logic -
- Template -
- Setting -
- Site -
These can be accessed by using an attribute name of the variable type, instead of the
For example, to get the site URL:
<Get url=site />
Most of the variable types have a tag as a shortcut. The above is equivalent to:
<Url site />
For details, see the page for each variable type.
template variable type is useful for storing templates, then rendering them later, or in multiple places.
This is in contrast to regular variables, which are rendered upon setting them.
For example, to create a reusable template:
<Set template=title_and_content> <h1><Field title /></h1> <Field content /> </Set>
It can be used anywhere, such as inside a loop.
<Loop type=page count=1> <Get template=title_and_content /> </Loop>