[All Adaptavist Apps]

Page tree

Description

This macro defines a flag and sets its state to either true or false.

If you've not already done so, it would be worth reading Working with Flags to gain a better understanding of what they are, why they are used and where to use them.

We recommend using Builder 3.3.6 or above to benefit from additional flag-aware macros.

Usage

{set-flag:foo}
{set-flag:foo|state=false}

Parameters

Property

Required

Default

Notes

Ver

default

(tick)

 

The default parameter defines the name of the flag (eg. 'foo' in the usage section above)

3.3.4

state

(error)

true

Defines the state for the flag:

  • true - set the flag to true (default)
  • false - set the flag to false, effectively clearing the flag

3.3.4

flag

(error)

 

The flag state is changed only if one or more of the specified flags are set. See Working with Flags for more details.

3.3.6

notflag

(error)

 

The flag state is changed only if none of the specified flags are set. See Working with Flags for more details.

3.3.6

Examples

Setting a flag

To set the 'foo' flag to state true, use:

{set-flag:foo}

Clearing (un-setting) a flag

To clear the 'foo' flag, set it's state to false:

{set-flag:foo|state=false}

Conditional setting of a flag

To set the 'foo' flag only when viewing a blogpost, for example, use:

{builder-show:context=blogpost}
 {set-flag:foo}
{builder-show}

Refer to builder-show macro, builder-hide macro, bubbles-show macro and bubbles-hide macro for a more complete list of the conditions that can be used.

CSS Customisation

When a flag is set to true a class will be added to the HTML <body> tag. For example, if the 'foo' flag has been set, the class will be called 'flag-foo' and will appear as follows:

<body class="flag-foo" ...

You can then prefix your CSS styles with this flag so that they only become active when the flag is set, for example:

.flag-foo h1 {
 color: #0f0;
}

In the example above the heading 1 colour would change to green when the 'foo' flag is set to true.

Hints and Tips

See Working with Flags for more information on working with flags and a full list of flag-aware macros.

Frequently Asked Questions

None at present.

  • No labels