If Boolean

Free!
Download
If Boolean
Description

A statamic 2.0 modifier that filters a multidimensional array (grid,bard,etc.) by a boolean/toggle field.

Copy IfBoolean folder into /site/addons/.

Usage

  • The first parameter should be the name of the boolean/toggle field to filter by.
  • The (optional) second parameter can be set to false for the opposite results.

If your data looks like this

ghosts:
  - 
    name: Casper
  - 
    name: Slimer
  - 
    name: Nearly Headless Nick
    humanoid: true
  - 
    name: Stay Puft
  - 
    name: Captain Daniel Gregg
    humanoid: true

Template

<ul>
{{ ghosts if_boolean="humanoid" }}
  <li>{{ name }}</li>
{{ /ghosts }}
</ul>
<br>
<ul>
{{ ghosts if_boolean="humanoid:false" }}
  <li>{{ name }}</li>
{{ /ghosts }}
</ul>

Outputs

  • Nearly Headless Nick
  • Captain Daniel Gregg


  • Casper
  • Slimer
  • Stay Puft

Important Links
Details
Released May 21, 2018
Downloads 171
Requires Statamic 2.0

Becky Soll

More by Becky Soll

Similar Addons

See All
A modifier to count the number of sets (by type) within a bard field.

Set Count

by Becky Soll in Modifier
A modifier to count the number of sets (by type) within a bard field.
Autolinks content wrapped in [braces], just like a wiki.

Wikilinks

by Statamic in Modifier
Autolinks content wrapped in [braces], just like a wiki.
Modifier to output a number as a currency

Currency

by Erin Dalzell in Modifier
Modifier to output a number as a currency