9th Nov '22
/
6 comments

Dynamic Data :value filter in Bricks

Bricks 1.5.7 introduced a new :value dynamic data filter.

This tutorial provides a practical example of how this filter can be used.

Meta Box Checkbox List

When a Meta Box Checkbox List type of field has both values and labels for the choices like this:

meta-box-checkbox-list-choices2

and let’s say a specific Page has the field populated like this:

To display the selected values as a comma-separated list, you could add a Basic Text component in Bricks and replace the default placeholder text with:

{mb_page_checkbox_list_inf0r0gxcl}

where checkbox_list_inf0r0gxcl is the field ID.

But this will output the labels, not the values:

Red, Green

This is where the :value filter comes in.

Tacking on :value at the end of the dynamic data tag like this:

{mb_page_checkbox_list_inf0r0gxcl:value}

will output the values instead (if that is what you are trying to show):

red, green

Now let’s say you want to output a Section only if red is one of the ticked choices value.

This can be done like this:

where the dynamic data tag is the same as before, with the :value filter:

{mb_page_checkbox_list_inf0r0gxcl:value}

ACF Checkbox

The :value filter is not needed with ACF since the Return value for a Checkbox type of field is set to “Value” by default.

{acf_color}

outputs comma-separated values:

red, green

Note: When Return Value is set to Label, using :value filter will NOT output the values. There does not seem to be a way to show the values without writing code in this case.

Get access to all 610 Bricks code tutorials with BricksLabs Pro

6 comments

  • Charles

    Found this page and have the same question as Michael above. Would love to find a way to output the items as a items. Or, really, even just replace the comma with another character such as a forward slash.

  • Michael Kern

    Is there a way to get Bricks to display these in a CSS-styled list instead of just comma-separated values?

Leave your comment

 

Related Tutorials..

Pro
Conditionally Rendering an Element Outside the Loop based on Taxonomy Term in Bricks

Conditionally Rendering an Element Outside the Loop based on Taxonomy Term in Bricks

A user asks: Hiding element based on taxonomy I have an element in a footer that I want to hide if a page has a…
Categories:
Pro
ACF Repeater sub field value dynamic data condition in Bricks

ACF Repeater sub field value dynamic data condition in Bricks

This Pro tutorial provides the steps to output an element on single posts (can be of any post type) only if a specified ACF (Pro)…
Pro
Primary Term Name and Link in Bricks when using Rank Math

Primary Term Name and Link in Bricks when using Rank Math

One of the features of the Rank Math SEO plugin is the ability to mark a term like category or product category as primary. See…
How to add a “Sold Out” badge for out of stock products in Bricks

How to add a “Sold Out” badge for out of stock products in Bricks

Looking to add a "Sold Out" badge for products in the Shop page for WooCommerce products that are out of stock when using Bricks' Products…
Pro
Custom Dynamic Data Tags in Bricks

Custom Dynamic Data Tags in Bricks

Bricks 1.5.7 introduced a new :value dynamic data filter. This tutorial provides a practical example of how this filter can be used. Meta Box Checkbox…
Weekday Condition in Bricks

Weekday Condition in Bricks

As of Bricks 1.7, the built-in "Weekday" condition does not work correctly. This is most likely due to it not taking the site's timezone (set…
Categories:
Checking for Post Type in Bricks

Checking for Post Type in Bricks

A way to output elements conditionally based on the current post type in the loop in Bricks.
Categories:
Pro
Month and Day Condition in Bricks

Month and Day Condition in Bricks

This Pro tutorial shows how we can define a custom function that takes in a month in the three-letter format (like Dec) and a day…
Categories: