Menu
All plugins
← All plugins
Inline Conditions

One element, different words.

Write an if, elseif and else straight into any Bricks field that takes dynamic data. The text changes with the value, so there is no second element to build and hide. It works with every dynamic data tag, tags nest inside the condition and inside the text, and nothing is added to the page.
Every result below is live. Pick a scenario and the page reloads with those values in the address bar, which the examples read with the URL parameter tag. With nothing in the address bar they assume 8 places on a safari. Rather not write the syntax by hand? Try the wizard.
Current values: places = not set, type = not set, guest = not set
Example 1

Several outcomes.

elseif adds as many outcomes as you need, and the text can carry other dynamic data. This is the places left rule: a number only appears when it is small.
{if:{url_parameter:places @fallback:'8'}<=0:Fully booked|elseif:{url_parameter:places @fallback:'8'}<=3:Only {url_parameter:places @fallback:'8'} places left|Places available}
Shows: Places available
Example 2

Singular and plural.

One tag fixes the wording around a number.
{url_parameter:places @fallback:'8'} {if:{url_parameter:places @fallback:'8'}==1:place|places} left
Shows: 8 places left
Example 3

Only when there is something to show.

is empty and is not empty test for a missing value. Pick Safari, 8 places or One place left to see the greeting.
{if:{url_parameter:guest} is not empty:Welcome back, {url_parameter:guest}.|Welcome.}
Shows: Welcome.
Example 4

And, or and not.

Combine tests with and, or and not, and group them with brackets. A condition is only checked as far as it needs to be.
{if:{url_parameter:places @fallback:'8'}>0 and {url_parameter:type @fallback:'safari'} contains safari:Book the safari|elseif:{url_parameter:places @fallback:'8'}>0:Book the tour|Join the waiting list}
Shows: Book the safari
Example 5

Matching a list.

in checks a value against a comma separated list. Text is compared without regard to case, and numbers are compared as numbers.
{if:{url_parameter:type @fallback:'safari'} in safari, expedition:Vehicle based|On foot}
Shows: Vehicle based
Example 6

Inside a query loop.

Each item in a loop is judged on its own. This lists the five newest pages on the playground and labels each one from its title.
{post_title}: {if:{post_title} contains Form:Form plugin|elseif:{post_title} contains Calendar:Date picker|elseif:{post_title} contains Inline:This page|Other page}
Colour Slideshow for Bricks: Other page
Colour Slideshow demo: Other page
Hardcopy: Other page
Content Explorer for Bricks: Other page
Content Explorer for Bricks: Other page
Example 7

In a link as well as in text.

The same tag works in a link field, so one button can send people somewhere different. Here the link goes to the documentation while places remain and to the plugin list when they do not.
Link: {if:{url_parameter:places @fallback:'8'}>0:https://bricks-playground.co.uk/docs/inline-conditions/|https://bricks-playground.co.uk/plugins/}
Text: {if:{url_parameter:places @fallback:'8'}>0:Open the documentation|Back to all plugins}