1

I'm very new to Craft 4.

  • I have a matrix 'Landing Page Blocks'
  • I've created 2 Block Types: Hero Block and Two Column Block
  • Within the 2 column Block I need a left and right content block
  • Within the left column block, editors can choose between and image or textblock. (same for right textblock.) (Each column can only have one block)

I can create this with a nested matrix field within the 'two column block'. But I'm not sure if that approach is correct? Will this approach give problems in terms of load times of create any other problems?

Thanks for your advice.

1
  • 2
    Hi and welcome. This is actually an excellent question, in my opinion. However I'm not sure it really fits well with the Stack Exchange Q&A format, as there is no real right or wrong answer here. It would be great to ask this in Craft's Discord server where a full discussion can take place of the pros and cons of different approaches. For what it's worth, I would split these into two different block types - "2 column text" and "Text | Image split". The text/image split on its own can get extremely complicated with various options. I would also have a hero as a completely separate matrix field. Nov 2 at 15:03

1 Answer 1

1

Here is the Craft Discord Info that James mentioned. https://craftcms.com/blog/discord

Your approach using nested matrices is one many developers use. Nesting too far, or creating "block" fields with many options and varieties will cause performance issues over time. You can also see a breakdown of performance if you're dealing with many sites in a multi-site setup.

I would advise not having the hero in the block builder. You have one hero per page, and its always at the top. so there's no advantage to having it inside the matrix field (which facilitates multiple blocks and repositioning) - as a disadvantage you're outputting that hero the least efficient way possible. Id recommend creating a set of fields for your hero (most performant), or a separate matrix with a min/max block count of 1 to house the hero (better author experience).

Ultimately, you'll need to weight the Author Experience v. the Performance and make your build choices from there. Here's some resources that might interest you:

https://craftcms.com/events/dot-all-2022/sessions/state-of-craft

https://craftcms.com/events/dot-all-2021/sessions/building-with-bumpers

https://nystudio107.com/blog/speed-up-your-craft-cms-templates-with-eager-loading

https://craftcms.com/events/dot-all-2022/sessions/using-entries-and-relationships-as-a-content-builder-system

Ultimately, you've hit a developer style conundrum, and you'll find that the real answer is "it depends". Hope these resources help!

1
  • Yes, thank you. I will check the resources first. Nov 6 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.