Dynamic Content Control: Implementing Hide/When Formulas in Your Headless CMS Content Model

What is Dynamic Content Control and Why is it Important?

Unlocking the full potential of a headless CMS requires more than just data storage; it demands dynamic control over content presentation. In this article, we explore the transformative power of implementing hide/when formulas for fields in your content model, revolutionizing how users interact with and consume content - right inside Agility.

Traditional content models often offer static display options, limiting users to predefined visibility settings. However, by integrating hide/when formulas, users gain flexibility to conditionally hide or display fields. This nuanced control empowers content creators to tailor the viewing experience, ensuring that users only see relevant information when and where it matters most.

How Does it Work?

Our hide/when formulas are based on a simple query language of operators and operands, which evaluate the values of other fields in your content model.

For example, this is a hide/when formula dictating that when the "description" is empty, the field that the formula is applied to will be hidden:

description[eq]""

We support 4 different operators:

  • [eq] Equals
  • [ne] Not equals
  • [lt] Less than
  • [gt] Greater than

We also support parenthesis, so you can get complex with your hide/when formulas, for example:

((age[gt]24&&name[eq]"Kevin")||name[eq]"Brendan")||admin[eq]true

To use a hide/when formula, navigate to your content model, click on the "Advanced" tab, and scroll down to these text inputs:

Hide/when field

Enter a hide/when formula and it will be applied to all content