Skip to content

LionsMouthDigital/Statamic-Array-Get

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Array Get

Get values from an array.

Usage

Use the modifier to get a value from an array.

  • Pass no param (within a loop) to grab the same index as the loop or
  • pass a key as a parameter to grab its value from the array.

Example (loopin'):

---
colors:
  - red
  - blue
  - green
---

{{ collection:blog }}
  <h1 class="text-{{ colors | array_get }}">{{ title }}</h1>
{{ /collection:blog }}

Example (pullin'):

---
message_colors:
  warn: orange
  error: red
  info: blue
messages:
  -
    level: warn
    text: Be careful.
  -
    level: info
    text: Did you know?
  -
    level: error
    text: Oh no!
---

{{ messages }}
  <h1 class="text-{{ message_colors | array_get:level }}">{{ title }}</h1>
{{ /messages }}

Releases

No releases published

Packages

No packages published

Languages