Craft CMS 5: Matrix Blocks Are Entries Now
Craft 5 came out a few days ago. The feature list is long, but nearly all of it follows from a single decision: Matrix blocks are entries now.
Dieser Artikel ist über 2 Jahre alt. Beschriebene Funktionen und Vorgehensweisen können sich seitdem geändert haben.
Craft 4.0 was mostly housekeeping: performance, a cleaner architecture, not much you could point at in the control panel. The visible improvements came later, in the dot releases. Craft 5 starts with them.
Matrix blocks are entries
In Craft 4, a Matrix block was its own element type, with its own database tables and its own block types. It couldn't do most of what an entry could: no field layout tabs, no UI elements, no conditions, no cards, no nesting. In Craft 5, Matrix fields manage nested entries, with no limit on how deep the nesting goes.
That one change explains most of the release. Nested Matrix fields work because an entry can hold a Matrix field. Entry types can be reused across sections and fields because blocks are entry types. Cards show up inside Matrix fields because entries already had cards. CKEditor can embed blocks in running text because those are nested entries. Icons and colors apply to blocks because they apply to entry types.
People have been asking for Matrix in Matrix since at least 2014. At the Craft CMS Summit that June, the closing Q&A came around to it, and the answer was that it was possible in theory but that getting the interface right would be the hard part. I wrote that down at the time without expecting to still be waiting ten years later.
The interface problem got solved by going around it. If blocks are entries, nesting doesn't need its own interface.
Longform content with CKEditor
Craft has always handled structured content well, but long-form writing meant choosing between two bad options. A plain rich text field lets editors write freely, but images and quotes end up as markup within a single field, with no way to address them individually. Discrete Matrix blocks give you that access and take the writing away: a text block, an image block, another text block, a quote, each in its own box.
Statamic solved this years ago with Bard, where you write in a rich text editor and drop structured blocks wherever you need them. In Craft, the equivalent has existed as a plugin for years, and still does: Vizy. I don't use it. When Craft 3 came around, I had projects built on Neo, which was the plugin everyone used for nested block types back then. The port took a long time, and I spent it waiting on someone else's release schedule with a content model I couldn't move. Since then, I've kept plugins out of content modeling wherever I can.
I test new features on CraftEntries before they go anywhere near a client, and this one has been running here since the beta. I'd want to watch someone else write in it before moving a content-heavy site over. But it's the first time this has worked without a third-party plugin.
A refined control panel
The UI has been touched up throughout. A collapsible global sidebar, a new icon set, better breadcrumbs. Anyone coming from Craft 4 will be at home immediately.
Entry type icons and colors
Entry types can be assigned an icon and a color, which carries through to the blocks inside a Matrix field. In a content builder with a dozen block types, that changes how fast you can scan a long entry.
Element cards
Element indexes and relational fields can display elements as cards with a large thumbnail and a customizable preview, rather than as table rows. Field layouts can also designate an Assets field to supply those thumbnails.
Inline content modeling
Building a content model used to mean juggling tabs. You'd start a section, realize you needed a field that didn't exist yet, open a new tab, create it, come back. In Craft 5, you can create a section, its entry types, and its fields in one workflow without leaving the screen.
Field instances
Most fields can now appear multiple times in the same field layout, each instance with its own name, handle, instructions, and conditions. A heading and a subheading used to mean two separate Plain Text fields. Now it's one field used twice. On a large project, this removes many near-duplicate fields from the Fields index.
Entry types are decoupled from sections as well, so the same entry type can serve several sections plus Matrix and CKEditor fields.
Bulk inline editing
Element indexes support inline editing of all visible elements from the table view. Select a handful of entries, change a shared value, save.
Before you upgrade
Craft 5 requires PHP 8.2. That's the first thing to check, because it decides whether the upgrade is a Craft question or a hosting question.
Most custom field content now lives in a central JSON column rather than in the content table. This is what makes the flexible content model possible, since it removes the MySQL row size limits that used to constrain how many fields a layout could hold. Not everyone was comfortable with that when it was announced, and the objection came down to JSON in a relational database looking like a step backwards. The counter-argument is that MySQL indexes inside JSON now, and that the historical reasons for shuddering at this don't all still apply.
There's also .eagerly(), which handles eager-loading for nested element queries without the setup eager-loading used to need. It's the developer-facing change I expect to use most.
The Team edition
Craft 5 also introduces a middle tier between Solo and Pro. Team costs $279 with $99 per year after the first year, allows up to five user accounts, and includes multi-site, GraphQL, advanced content previewing, and developer support. It has no user groups and no permissions.
In February I wrote about the pricing discussion and about what a middle tier would have to do. Team answers part of that. The gap between free and $399 is narrower now, and that was the central ask. But it includes GraphQL and multi-site, which is exactly what makes a tier expensive in the first place, and the renewal stays at $99 a year, the same as Pro. The entry price drops once. The recurring cost, which is the number clients compare, doesn't move at all.
Conclusion
The interesting thing about Craft 5 isn't the length of the feature list. It's that one architectural decision produced most of it, and that the decision was ten years in the making.
Longform is the visible payoff and the reason to upgrade a content-heavy site. But the part I'll notice for years is that the distinction between a block and an entry is gone. Check the full changelog for everything not covered here.