Template Tags
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 feature:new_product}
<p>Show me the money!</p>
{/if}
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.
{exp:channel:entries channel="pages"}
<h1>{title}</h1>
{/exp:channel:entries}
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.

{exp:channel:entries channel="pages"}
<h1>{title}</h1>
{bloqs}
{conditional_display}
{if display_content}
<!-- Since all the other bloqs are children of the
Conditional Display bloq will display based on the condition
of the Display Content field. -->
{bloqs:children}
{/if}
{/conditional_display}
{related_entries}
...
{/related_entries}
{asset}
...
{/asset}
{/bloqs}
{grid}
{if grid:display_content}
<!-- This text will display if the
new_product flag is enabled and active. -->
{/if}
{/grid}
{/exp:channel:entries}
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:
{
new_product: true,
ab_test_carousel: false
}
Last modified 7mo ago