Stacks API

Come build with us.
Stacks API v6 for Stacks 2.5


  <   Templates Variable Reference


Conditional

%[if true ]% %[else]% %[endif]%

This content is open source. You can edit it and submit a pull request on GitHub.
This page is generated from this file.


© . YourHead Software all rights reserved.

Conditional

%[if true ]% %[else]% %[endif]%

Available: Stacks API v3

Usage

%[if <expression>]%
    content displayed when <expression> is true
%[endif]%

or

%[if <expression>]%
        content displayed when <expression> is true
%[else]%
    content displayed when <expression> is false
%[endif]%

Note: Integer values are converted to boolean using the C language rules (e.g. 0 => False, all other values => True).

Description

Conditionals allow you to add or remove content to the generated HTML based on the value of the conditional argument.

Conditionals may be nested.

Example 1: Display a message when checkbox is checked.

%[if %id=checkbox% ]%
    Checkbox is checked.
%[endif]%

Example 2: Display an element using CSS when a checkbox is checked.

.elementClass {
    %[if %id=checkbox% ]%
        display: block;
    %[else]%
        display: none;
    %[endif]%
}
© . YourHead Software all rights reserved.