Matrix field within a Matrix field #8101
-
Sometimes, you just need a matrix within a matrix. For example, if i have a content building field setup using a matrix that allows the user to add blocks of content, sometimes they may need a content block that needs repeating content itself. |
Beta Was this translation helpful? Give feedback.
Replies: 37 comments 37 replies
-
@phil I think I'm in agreement with you on that. @brett UI proposals are absolutely welcome! |
Beta Was this translation helpful? Give feedback.
-
Brandon, knowing that the PHP code is mostly in place is exciting. I can certainly appreciate the UI challenge this poses. Would you ever consider accepting UI proposals from folks in the community? I realize Craft isn't open-source (and we're all much better off for that), but I bet people would be more than happy to toss their ideas into the ring as a way of helping bring this specific feature to life. |
Beta Was this translation helpful? Give feedback.
-
I've had this come up a few times now. I have to say though, I haven't run into any cases (and am hard pressed to think of any) where more than one level of nesting would be needed. Another option that might be worth considering would be to expand the columns types in Table fields. In all my cases, that would've been a fine solution, so I posted that idea over here: #811 |
Beta Was this translation helpful? Give feedback.
-
So much yes! |
Beta Was this translation helpful? Give feedback.
-
I don't fully understand Hierarchical Matrix fields, but the idea posted here is great. I'd never seen the need for it before, but an agency I'm working with at the moment is right in the middle of implementing this Matrix > Playa > Matrix setup in EE for letting users create content blocks. If we could do it even better in Craft, that would be awesome! |
Beta Was this translation helpful? Give feedback.
-
This comes up all the time, love the idea of it, appreciate the UI could be challenging, but you guys love a challenge! Also like the sound of the alternative matrix hierarchy. Even a simple matrix in matrix offering similar content types to the native table fieldtype but with the addition of linking to elements, would solve a load of my problems - Probably a plugin :) |
Beta Was this translation helpful? Give feedback.
-
Here’s an alternative idea that might do a better job solving the same sorts of content problems: #827 |
Beta Was this translation helpful? Give feedback.
-
We would really love to add this, and most of the PHP code has already been set up for it, in fact. The only problem is, we haven’t been able to come up with a satisfactory UI for it. Things just get way too confusing when you start having blocks within blocks (or even blocks within blocks within blocks...). The other option is a modal window, but then you lose context, which isn't great either. |
Beta Was this translation helpful? Give feedback.
-
Matrix in a matrix is required. I had a similar problem with ACF Flexible Fields which is Wordpress' third party plug in equivalent. The plugin creator did add one in the end. Things become quite messy without one. In a lot of cases especially simple websites you could quite easily get away without one but if you are embarking on a complex site or thinking out of the box with a particular creative project then not having one means quite simply CraftCMS is too limiting for your requirements which is a shame as I would like to think that CraftCMS gives you more freedom than Wordpress does. |
Beta Was this translation helpful? Give feedback.
-
Have you had a look at Neo, already created for Craft 2, which is the release to build with for the coming 6-9 months? https://github.com/benjamminf/craft-neo There's also Supertable, which may take care of your more actual needs. You're far from the only person with an interest here; would expect matters to come out nicely -- according to use-cases, and when the beta becomes nearer to release. You might try listening in on Craft Slack #craft3 for information when there are developments. p.s. just noticed the stream above your added post. Would think that's pretty generous taking care of the situation also -- the Craft team is as good as it gets in creating real, usable things -- always with depth and thoughtfulness, proactive to real needs. |
Beta Was this translation helpful? Give feedback.
-
@takobell your (at least) last 2 solution links are dead. Any news from the devs regarding this issue? (BTW. adding existend fields to block types in a matrix would be pretty awsome too IMO) |
Beta Was this translation helpful? Give feedback.
-
@stablestorage Just fixed those two links. Take a look at Neo, as @narration-sd suggested. |
Beta Was this translation helpful? Give feedback.
-
Forget matrix within a matrix for second, It would be ideal if Matrix simply just did one additional level, maybe even call the first level a container blocks or something. From a UI standpoint, it does gets super weird the deeper you go. But just having one more level would be ideal for at least 99% of my use cases. It's pretty common to be able to have a container block and then have sub blocks underneath it when creating a grid like layout. An accordion field type is a another good example: there's no good way to setup an accordion with a single Matrix instance especially if you want to mix and match other blocks like images, content, etc. Forge the pipe dream that is multiple inception, I would vote for one additional level if it simplifies development and we get it in Craft 3. |
Beta Was this translation helpful? Give feedback.
-
Hmm. It's a nice sounding idea at first, but doing it this way would seem to involve similar code to full recursive ability. And it wouldn't help the use case, which sounds valid as some sort of newspaper or other complex and often-updating document, being explored in #2009. For the present, wouldn't using a Supertable as first layer allow what you'd propose? |
Beta Was this translation helpful? Give feedback.
-
@narration-sd Not sure I follow? I like Super Table and Neo. Some really good plugins there I hope P&T take into account. One goal for client sites is to not rely too heavily on 3rd party plugins if possible. Matrix is a great feature but it becomes less compelling if you end up having to use Neo or Super Table as well. (One of the reasons we moved away from WP was the plugin churn.) Just having one more "container" layer opens up a few more possibilities that simply aren't available with one layer matrix, accordion being one big one or anytime you want to make an FAQ section or gallery section. The problem now is there's no clean way in Twig to say "Hey I'm done building out the content modules/blocks for this section." It's like a wrapper div. Just going one layer into inception would solve a lot of use cases IMO, similar (but not exactly) what Super Table does. Your container at the top wouldn't be the same blocks as the container in middle, they would be different. From this thread It seems as if P&T has code in place to handle the complexity, it's a matter of making sure the UI among other things doesn't break the deeper you go. At some point you run out of room showing the "levels." Threading comments is a good example. At some point, you just stop indenting them. But that wouldn't work in this case. Simply allowing one layer beyond what we have now would be an excellent compromise IMO that would benefit a lot of people without having to go into the hell that is multi-layer inception. And let's be honest, we try to keep this simple for our own clients, I don't want them doing too much with layout... IN WP Land, ACF's Flex Content field is also another example in the wild of how this could work. But I think there's some UI Polish the guys at P&T could do as usual! |
Beta Was this translation helpful? Give feedback.
-
@angrybrad Imagine nesting semantic elements like this:
A good example is at iPadOS page where sections are nested to more blocks related to What heading of section is about. Matrix field within a Matrix field or one level of fields deeper that @RitterKnightCreative had mentioned would solve this kind of situation. |
Beta Was this translation helpful? Give feedback.
-
With the statement of @brandonkelly in mind:
What is the status regarding the nested matrix fields? We are using Neo until now, but they still need to adapt to Craft 3.5 and one less plugin is always a good thing. |
Beta Was this translation helpful? Give feedback.
-
@jerome2710 it’s tricky because we can’t migrate Matrix sub-fields into normal global fields via a typical migration. That will likely lead to a lot of people getting errors about their |
Beta Was this translation helpful? Give feedback.
-
@brandonkelly thank you for the update. I can imagine this has quite some impact on the how the content is stored. We will stick to Neo for now as this suits our needs at the moment and follow this issue as it evolves. If you could keep us up to date here regarding changes in either Craft 3 or 4, that would be great! |
Beta Was this translation helpful? Give feedback.
-
If all matrix sub fields are going to be global fields, |
Beta Was this translation helpful? Give feedback.
-
Totally up to you. |
Beta Was this translation helpful? Give feedback.
-
If P&T successfully recreates all the core functionality of Neo, I imagine the Neo dev would stop updating the plugin. IIRC he did just that for an earlier Craft version (2.x, I think?) for a similar reason, but caved to popular demand and made Neo 3.x compatible when that Craft version was released. |
Beta Was this translation helpful? Give feedback.
-
Neo was originally written by @benjamminf and then transferred to his former agency, @spicywebau, when he took a new job elsewhere. Spicy is aware of our plans, but happy to continue supporting & maintaining (& profiting from) Neo for the time being. Up to them but I doubt they will port to Craft 4, and wouldn’t blame them if they didn’t. Again, there will be a migration path for Super Table & Neo fields in Craft 4, so you won’t be stuck if you go with them today. |
Beta Was this translation helpful? Give feedback.
-
I just came across what is IMO a killer feature of Neo that I had no idea about until I was today years old. I think it's probably well-known that in Neo, you can have blocks nested in other blocks. What might be less well-known is that you can drag blocks into and out of other blocks (if those other blocks are configured to allow the dragged blocks to be added as child blocks, of course). You can also drag sub-blocks from one parent block to another parent block. Just wanted to bring it to your attention so that it doesn't get accidentally left behind in Craft 4's Matrix. 😉 |
Beta Was this translation helpful? Give feedback.
-
Any update on when this will be incorporated in Craft 4? |
Beta Was this translation helpful? Give feedback.
-
It seems that this feature has been postponed to v5.x 😢 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I have just been maintaining Craft installations for the past year or so — I haven’t built a new site with Craft 4 as of yet. But I’m in the process of starting a few new sites with Craft 4, and I must say that I’m somewhat shocked that nested matrix fields are still not a thing!? I posted about this while C4 was still in beta, and I was assured that I could do away with Neo because the same functionality would be rolled into C4. Beyond just the nested fields, I have also relied heavily on reusable fields instead of creating a new field for mundane things like a drop-down that maps to a css background class. Or a plain text field that can act as header text, or a label. These are just fanciful examples but maybe there’s a better way to approach how I’ve been doing things? Maybe I should reconsider reusing fields this way in NEO? Anyway, I’d love to know where the matrix situation lies and if we’re ever going to see that which was promised in Craft 4. |
Beta Was this translation helpful? Give feedback.
-
I hope that the new Nested Matrix fields offer the option to choose a similar display to the SuperTable? |
Beta Was this translation helpful? Give feedback.
-
We made it possible to create nested Matrix fields in Craft 5 🎉 |
Beta Was this translation helpful? Give feedback.
We made it possible to create nested Matrix fields in Craft 5 🎉