Craft 5, Matrix Entries, & Custom Sources

So the grand "entrification" of Craft has begun! Craft 5 is here, and the first to be assimilated into the all-consuming Entry is the Matrix field. Gone are the days of Supertable and Neo – Craft now has native Matrix nesting! And alongside that, we can also generate new entries directly from other fields, like CKEditor rich text inputs. It's an exciting time, with lots of new content modelling possibilities, but it also creates some weird paradoxes around what is or isn't treated like an Entry.

For instance, you might think that if you have an existing Entry type, with existing content, and add this to a new Matrix field, that an Entry created via that Matrix field would show up in the same entry lists as all of the old content, right? Wrong! Because whilst Matrix content is now "just" entries, some things don't treat them in the same way as other, well, entries, even where the Entry Type is the same 😅 Indeed, it seems like loading more functionality into the Entry umbrella has – and no one could have seen this coming – overloaded the term a little.

The result is that a lot of the CMS functionality you're used to using no longer works quite as expected. Take filtering, for instance. In Craft 4, the list of Entry types that I'd see if I went to my Settings panel would be exactly the same as the list available under the Entry Type filter, but now most are missing. On the other hand, if I go to a Matrix field and expand the Entry Type dropdown list, they're all visible again. So it seems that something is or isn't a valid Entry Type based on the context in which the question is asked? In some places, an Entry Type only counts if it's assigned to a Section; in others, that isn't a limitation at all.

With that in mind, does the behaviour within entry lists make any more sense? Well no, not really. When I create a Section and assign any Entry Type to that Section, Craft generates a new entry list view, with the Section name as the title. Clicking on that view brings up all of the entries of that specific Entry Type – or at least, it used to. Now it ignores Matrix-specific entries entirely! And what about the default "All Entries" view, does that contain entries created within a Matrix field? Nope, they're missing their, too. This would be fine (naming confusions aside) if there was a clear delineation between Matrix "entries" and Entry "entries", but there isn't. You can use any Entry Type when defining either a Section or a Matrix, but they're only visible as an independent entry if they are used by (and created from) a Section.

Okay, that's weird and all, but why is it an issue? Because sometimes you want to use an Entry Type in multiple places. For my purposes, I'm building a check-in (or Visited) system alongside a journaling model. I want to be able to create journal entries that let me log where I've been, so I create a Matrix field and let it generate new Visited entries. But sometimes I'll go somewhere that doesn't warrant a full write-up. In that instance, I want to create a Visited entry directly. Craft lets me do this; I can have it both ways. But when I go and look at the list of Visited entries, it's now incomplete. So if I'm pulling together my end of year analysis (in May), I can't use Craft to see how many places I've been over the last twelve months, as some of them are hidden. Or if I want to edit all of the Visited entries, I can't use bulk editing any more, and instead I have to go into each entry that contains a Visited entry within a Matrix field, and amend it there. (Don't even get me started on how you'd even be able to track those down 😬)

At least, that's what I thought I would have to do. I was just about to throw in the towel and revert to Craft 4, with the much easier to comprehend Supertable plugin, when someone on the Craft Discord asked me whether I could use a "Custom Source" to solve my problems. A what?

It turns out that you can make your own custom entry lists. I've been using (and paying for!) a plugin since Craft 3 just to expand Sections that have multiple Entry Types in my Entries panel sidebar, and apparently I could have created my own sidebar shortcuts using a powerful, but almost entirely hidden, feature instead[1].

If you go to your Entries panel in the Admin CP, at the very bottom of the list there will be a stealthy kebab menu (three horizontal dots). This hides a solitary option: Customise Sources[2]. Clicking it launches a modal window, within which you can completely modify your sidebar layout. You can add section titles, move lists around, and even disable the automatically generated ones entirely. You can also create new "sources" (or what I call lists; "sources" isn't a great name, imo), applying any of the usual filters to generate a unique subset of entries. To be blunt, it's a remarkably useful tool! But does it solve my problem? No one seemed to know on the forums, so I did some digging, and it turns that yes, yes it does 🥳

The triple-dot kebab menu selected, showing a single fly-out menu option: customise sources.
Perhaps the kebab menu is space-saving compared to the giant label, but I can't help but think that "Edit" or "Edit Sidebar" would work quite well here instead.

One of the filter options is "Matrix Field". Select that and you'll be treated to the exact same UI as if you'd selected "Entry Type", only this is the inverse subset: only Entry Types that are used by Matrix fields. So if we return to my issue above, I can select the Visited type, and get a list of all Visited entries used by Matrix fields.

Custom source menu, with a label field with the value of "rewatched" and a filter applied. The filter has "Matrix field" selected in the first dropdown; "is one of" selected in the second dropdown; and "rewatches" selected in the multi-select.
I was ridiculously excited when I discovered this hidden filter option; shame it didn't quite work 😂

Unfortunately, adding another filter appears to operate with AND logic, so if you ask for Visited entries used by Matrix fields and the Visited Entry Type, you only see those used in Matrix fields. Fortunately, however, you don't need to do that. For whatever bizarre reason (and I pray this isn't a bug that gets removed 🙏), if you instead only select the Entry Type filter, with "is one of" pointed at Visited, it works as you would expect, showing all entries of that type regardless of where they were created. Matrix fields, directly, it doesn't matter, there they are.

Custom source menu with "visited" as the label, "Entry type" selected as the filter, and the filter settings of "is one of" and "updates - visited".
The whys and wherefors of Craft's current Entry considerations are beyond mere mortals like me, but this is probably the setup you want.

So if you have an Entry Type that is only ever created by Matrix fields, you can set up an entry list using the Matrix Field option. Or, if you have one used in multiple places – including by a Section – then use the Entry Type option. Clear as mud 😂

Explore Other Articles

Newer

Crafty Field Migration

Migrating content between fields in Craft is not as simple as it might be. In the wake of Craft 5, I've been getting a lot of practice, and wanted to write up some of the techniques I've been using.

Conversation

Want to take part?

Comments are powered by Webmentions; if you know what that means, do your thing 👍

Footnotes

  • <p>Craft 5 introduces entry-based Matrix fields, but being able to see the entries created this way is surprisingly tricky. Thankfully, it can be done!</p>
  • Murray Champernowne.
Article permalink