Matrix fields

If you’ve ever worked with a hairball of content and markup managed in an increasingly-fragile WYSIWYG field, you’re probably going to like Matrix blocks.


Matrix blocks are groupings of fields an editor can use to build and rearrange content. They can be critical in supporting flexible, customizable content for an editor that’s balanced with the kind of discrete, well-modeled content a developer wants to work with.

Think of matrix fields like multiples but within a singles section. It is for displaying content that tends to be repeated.

The template syntax for looping through Matrix fields is as follows:-

@foreach ($matrixHandle as $row) @if( not_empty('fieldHandle', $row) {{ print_content('fieldHandle', $row) }} @endif @endforeach

Matrix fields can be used anywhere, in Singles, Multiples, or Globals. It is a perfect way creating and displaying repeated content.