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 342
Requires Statamic 2.0

Becky Soll

More by Becky Soll

Similar Addons

See All
Filter tag pairs by expiration date

Expires On

by Becky Soll in Modifier
Filter tag pairs by expiration date
Extends the default Bard (MediumEditor) anchor functionality with internal links selection.

Anchor Extension

by Frederik Sauer in Enhancement, Modifier
Extends the default Bard (MediumEditor) anchor functionality with internal links selection.
Autolinks content wrapped in [braces], just like a wiki.

Wikilinks

by Statamic in Modifier
Autolinks content wrapped in [braces], just like a wiki.