craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

Matrix field within a Matrix field #812

Closed angrybrad closed 3 years ago

angrybrad commented 7 years ago

Created by: John Baxter (john@luckyturnmedia.co.uk) on 2015/03/11 09:07:25 +0000 Votes at time of UserVoice import: 118


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.

angrybrad commented 7 years ago

Posted by Brandon Kelly (brandon@pixelandtonic.com) on 2015/03/06 03:54:45 +0000

@Phil I think I'm in agreement with you on that.

@Brett UI proposals are absolutely welcome!

angrybrad commented 7 years ago

Posted by Brett Burwell (bburwell@thisisstatic.com) on 2015/03/18 21:23:48 +0000

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.

angrybrad commented 7 years ago

Posted by Phil Zelnar (phil@andphil.com) on 2015/03/18 20:09:09 +0000

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

angrybrad commented 7 years ago

Posted by Anonymous (Connnor@ConnorVG.tv) on 2015/03/17 11:54:30 +0000

So much yes!

angrybrad commented 7 years ago

Posted by Daryl (craft@codeknight.co.uk) on 2015/03/12 09:36:29 +0000

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!

angrybrad commented 7 years ago

Posted by Sam (sam@fruitstudios.co.uk) on 2015/03/10 22:17:30 +0000

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 :)

angrybrad commented 7 years ago

Posted by Brandon Kelly (brandon@pixelandtonic.com) on 2015/03/06 03:54:45 +0000

Here’s an alternative idea that might do a better job solving the same sorts of content problems: #827

angrybrad commented 7 years ago

Posted by Brandon Kelly (brandon@pixelandtonic.com) on 2015/03/06 03:54:45 +0000

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.

cannon303 commented 7 years ago

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.

narration-sd commented 7 years ago

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.

sem4phor commented 7 years ago

@takobell your (at least) last 2 solution links are dead. Any news from the devs regarding this issue? It would be really nice that if you create a matrix (a), you should be able to add another matrix (b) as a field of Matrix (a) and so on... This would support DRY fieldingso much!

group 2 2x

(BTW. adding existend fields to block types in a matrix would be pretty awsome too IMO)

brandonkelly commented 7 years ago

@stablestorage Just fixed those two links.

Take a look at Neo, as @narration-sd suggested.

RitterKnightCreative commented 7 years ago

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.

narration-sd commented 7 years ago

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?

RitterKnightCreative commented 7 years ago

@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!

brandonkelly commented 7 years ago

@RitterKnightCreative Sounds like you are describing/looking for #827

proimage commented 6 years ago

Regarding the UI for Matrix-ception, and inspired by the mockup above, why not "recreate" the Mac OS X Finder interface for viewing sub-(sub-sub-etc)-folders—the one where each nested folder level is a column in the Finder window?

graham73may commented 6 years ago

I'm finding it a little hard to gauge from the comments in this issue and the hierarchical issue... How likely is it that this feature will one day land in core? (This issue remains open so I'm hopeful!)

As mentioned above, one level deep would solve the vast majority of use cases where we've required this.

millman2394 commented 5 years ago

I find myself needing this functionality, but it doesn't look like it will come anytime soon :(

brandonkelly commented 5 years ago

It’s planned for Craft 4! In the meantime you can use Super Table (free) or Neo ($49). Craft 4 will have built-in migrators for both of those field types, so you don’t have to worry about the upgrade path.

proimage commented 5 years ago

Super-exciting news, Brandon!! Will Craft 4's Matrix field still use custom-built fields specifically for each block, or is it going to adopt Neo's practice of using (or at least being able to use) pre-existing custom fields?

brandonkelly commented 5 years ago

All Matrix sub-fields will be global fields in Craft 4.

dominikkrulak commented 4 years ago

Posted by Phil Zelnar (phil@andphil.com) on 2015/03/18 20:09:09 +0000

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

@angrybrad Imagine nesting semantic elements like this:

<section>
    <h2></h2>
    <section><h3></h3></section>
    <section><h3></h3></section>
    <section><h3></h3></section>
</section>
<section>
    <h2></h2>
    <section><h3></h3></section>
    <section><h3></h3></section>
    <section><h3></h3></section>
</section>

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.

jerome2710 commented 4 years ago

With the statement of @brandonkelly in mind:

Brandon Kelly - 07/10/2020 no ETA for v4 at the moment. Originally that was going to be this year's focus, but due to "unforeseen circumstances" we decided to hold off on that, as it doesn't seem like the right time to release a big breaking update. We are going to continue releasing 3.x updates with as many of the things we originally planned for v4 as we can w/out breaking anything.

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.

brandonkelly commented 4 years ago

@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 content table having too many columns. So it needs to come hand-in-hand with some refactoring of how content is stored as well. So most likely it all needs to happen together in Craft 4, although there may be a way we could introduce it earlier as an alternative form of content storage that bypasses the current stuff.

jerome2710 commented 4 years ago

@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!

hongc-cc commented 4 years ago

If all matrix sub fields are going to be global fields, it sounds like we should stick to Neo since the architecture is similar?

brandonkelly commented 4 years ago

Totally up to you.

proimage commented 4 years ago

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.

brandonkelly commented 4 years ago

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.

proimage commented 4 years ago

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. 😉