Using the Batch Filter in Twig


Using the Batch Filter in Twig

Sometimes when outputting content we need to adhere to layout requirements and break the content up into rows, columns, or some other layout. A common example is break up the content into columns of a specific length. This can be done by counting the output and inserting markup at certain points in the loop. But Twig makes it simpler using the batch filter. Let's learn how.

Lesson Overview

How to use the batch filter instead of conditionals to control multi-column layout.

Taught by Ryan Irelan

More on Craft CMS

Lesson Materials