October CMS resources and help articles

Simple and to the point. Optimized by the community.

RainLab.Pages: Custom page field cheatsheet

5
by OFFLINE, last modified on May 13th, 2020

This is a short cheatsheet for Custom Page Fields:

String

{variable name="variableName" tab="tabName" label="fieldLabel" type="text"}{/variable}

Use in twig:

{{ variableName }}

Textarea

{variable name="variableName" label="fieldLabel" tab="tabName" type="textarea"}{/variable}

Use in twig:

{{ variableName }}

Checkbox

{variable name="variableName" tab="tabName" label="fieldLabel" type="checkbox"}{/variable}

Use in twig:

{% if variableName %}

Mediafinder

{variable name="variableName" tab="tabName" label="fieldLabel" type="mediafinder"}{/variable}

Use in twig:

{{ variableName | media }}

Dropdown

{variable name="variableName" tab="tabName" label="fieldLabel"
options="Option1|Option2|Option3" type="dropdown"}{/variable}

or

{variable name="variableName" tab="tabName" label="fieldLabel"
options="one:Option1|two:Option2|three:Option3" type="dropdown"}{/variable}

Use in twig:

{% if variableName == 2 %} {# This means Option2 is selected. #}
or 
{% if variableName == two %} {# This means Option2 is selected (with keys). #}

Repeater

{repeater name="repeaterName" prompt="Add an item." tab="tabName"}
    [...]
{/repeater}

Use in twig:

{% for repeaterItem in repeaterName %}
    [...]
{% endfor %}

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?