Conditional Content supports a wide selection of conditions, such as device, user groups, date ranges, languages, menu items, and more. These conditions define when or to whom you want to show the content.
By clicking on the Conditional Content editor button, you will be able to insert all the available conditions in an easy-to-use interface, as part of the "Conditions" tab.
If all of the conditions are set to Ignore
, the piece of text will show up (when using {show}
) or be hidden (when using {hide}
) on all pages. As soon as you set one or more of the conditions to Include
or Exclude
, the piece of text will be limited to the specified conditions.
Matching Method
As mentioned above, you can use and combine any of the conditions. You don't have to just use one.
To control how multiple conditions are applied, there is a Matching Method option. This determines whether all or any conditions need to be matched:
- ALL: Will be published if ALL of the below conditions are matched at the same time.
- ANY: Will be published if ANY (one or more) of the below conditions are matched at any time. This will add a
matching-method="any"
attribute in the plugin tag.
Condition rules where "Ignore" is selected will be ignored.
Note: When setting any or more conditions to Exclude, the Matching Method should be set to ALL. Otherwise, using ANY would result in one Exclude condition to always match and the piece of text to show everywhere else.
Condition States
Each condition type has three possible states/options.
- Ignore (default)
- Include: the content will be shown/hidden in all circumstances that do match that condition.
- Exclude: the content will be shown/hidden in all circumstances that do not match that condition. This will add a
!
after the condition type name in the plugin tag.
By default all conditions are ignored, meaning the condition is not used.
To use an condition, you set the option to Include
or Exclude
depending on the desired effect.
Condition Sets
Conditional Content comes with the ability to save and reuse complete Condition Sets. These sets can contain one or more rules in all sorts of combinations.
You can either create a new Condition Set and use that. Or use an already existing Condition Set.
The great advantage is that you can not only reuse the same Condition Set in different Conditional Content tags. But also reuse them in Advanced Module Manager and ReReplacer Pro!
Another advantage is that you can create complex conditions containing multiple rules that are grouped and mix different matching methods (ALL / ANY). While the syntax remains sweet and short. Just the condition="..."
attribute is necessary.
And a third advantage is that you can name the condition set to make it easier to understand what is going on.
For instance, you might struggle a bit when trying to understand:
{show menuitems="23,57,108"}...{/show}
Placing this in a well-named Condition Set will save you some brain cells every time you go back to that content:
{show condition="Legal Pages"}...{/show}
And the last advantage (but you can probably think of more) is that the Condition Sets give you the ability to use more Rule types and settings. The inline conditions only support a subset of the available conditions and do not offer the ability to use Rule settings, like "Also on child items", etc.