Template Tags
Last updated
Last updated
Anywhere in your template you can reference an early parsed global variable for each feature flag to determine if content shouldbe shown. In this example if the new_product feature flag is enabled and active, then the text will be rendered.
If a Feature Flag field is added to a channel you do not need to modify your template to show or hide the entry content. For example, the following custom field is added to a channel, and when editing an entry you will see in plain text what it wants to do. If the last dropdown option is set to "Hide" this entry, then the channel:entries
tag will automatically remove the entry from the result loop if the new_product
feature flag is enabled and active. If it is set to show, then it will only display the entry in the channel:entries
tag when the new_product
feature flag is enabled. If it is not enabled, it will skip the entry when looping over the channel:entries
tag results.
A Feature Flags field when used as a channel field is the only time you won't be required to add a template conditional tag to show or hide your content.
If you add a Feature Flags field to Bloqs or Grid you will need to add a conditional to your template tag for this to work. For example we have 2 Conditional Display bloqs below. The first will display itself and it's child bloqs if the new_product feature flag is enabled and active. The second will not display itself or it's children if the feature flag is enabled and active.
You can reference a feature flag in JavaScript if you add the {feature_flags:all} tag to your document, which will output JSON encoded string of the flags available, and their current status. For example: