Skip to content

Laravel’s Array Get for Statamic

I use this addon in every Statamic project

A heard of fuzzy goats gather on a gravely, arid valley. Several goats look straight at the camera.

The addon (people) wading through your array of data (goats!) to find the right datum (goat). For more weak tech analogies, hit me up on Twitter. | Photo by nima hatami on Unsplash

Margaret Thatcher, Ronald McDonald, David Bowie, Zendaya, Vanessa down the street. What do these people (does Ronnie count as a person?) have in common? Hell if I know.


I wrote a Statamic 3 addon that I’ve been copying and pasting into every Statamic project I work on. It’s basically Laravel’s Arr::get() helper in Antlers. I used something similar in v2 back when Jim-Jam and I cranked out Statamic builds left and right and I more actively battled my nemesis.

Left: Jim-Jamm, wearing a hat and looking off into the distance.  Right: My nemesis, with a devilish grin and horns scribbled on

Left: Jim-Jam | Photo pulled from Twittah 🐦. Right: My nemesis | Photo also pulled from Twistah 🌪

It helps me:

  • Streamline my markup

  • Easily add new variants (especially easy for minor differences like colors, sizes, padding… all that jazz 🎷) (doubly-especially wonderful with Tailwind)

  • Allow content authors to oh-so-simply choose which variant to render

  • And probably some other stuff not coming to mind right now 🤔

Anyway, check it out on GitHubPackagist, and the Statamic Marketplace. Let me know if you come up with more interesting use cases or if you run into any problems!

Array Get addon code with Highland's logo in the lower right corner.

Addon in the Statamic MarketplaceOh, yes. One other neat thing I didn’t document because it’s more of a side effect than an intentional feature: Array Get allows you to throw Antlers code in your front-matter and have it parsed in the output. I did that all the time in v2 (and probably v1?), but (last time I checked) v3 doesn’t support Antlers in your front-matter.

You might also like