-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit Matrix Blocks Per Block Type #826
Comments
Definitely could use this. I often create a matrix block for a page which allows content editors to shuffle the order of blocks, but it wouldn't make sense to allow creation of more than 1 of each block type. The way the matrix works right now seems suited to article pages for blogs posts but it definitely has other powerful uses. |
Hopefully this ends up in core some day, but for the interim I just published a new plugin which hacks it in: https://github.com/mmikkel/limitblocktype – may be useful to someone :) |
+1 Just needed to use this on a website where I only wanted 1 hero header (A block in a Matrix) and also only 1 map block. All the other blocks could be an unlimited amount. But if I could restrict the map / hero header blocks to just 1 this would save a massive confusion on the clients side. |
ACF (WordPress) has this feature in their Flexible Layout fieldtype (which works a lot like Matrix), and I really miss it in Craft. A frequent use case for me is using Matrix fields as "layout" builders, where block types are basically pre-baked (more or less) site sections such as "Contacts listing", "Pricing table" etc., where I don't want the client to be able to add multiple "Contacts listing" or "Pricing table" blocks per field. It isn't a huge issue as I can always filter out the extra blocks w/ Twig, but it'd be super nice to have the option to set a limit per type. |
I was thinking about this the other day. A case I ran in to is a block for "media reviews" (or testimonies) on a product information/landing page. You don't necessarily care what order the blocks are, but if you wanted to limit them to only having one row of reviews, that's not possible. |
The use case could also be covered by the conditional field display feature request... there are times when I like the simplicity of showing options as a matrix button but I don't want them to be able to use more than a single type of block. My particular use cases could all be replicated by having optional fields listed out but I think it makes a lot more sense to my users to have the matrix button available and if they aren't going to use the fields in question they don't have to see the fields not in use. Basically I think it comes down to preference - my preference in most cases would be to use matrix blocks even if they are optional fields (for instance the background in a header image) because it is easier for my clients to understand and easier to look at... plus with matrix you get the added flexibility of block groups, disabled blocks, and the ability to reorder content. Just the way I look at it - I would be happy to explain more if need be - I know I didn't do the best job! |
What's the use case? |
Closing in favor of #3350. |
The text was updated successfully, but these errors were encountered: