Block Usage plugin for Craft CMS 3 and 4
If you’ve been around Craft long enough and have had the opportunity to work on any large-scale projects with Matrix/Neo fields, you’ve most likely hit the dreaded "Row size too large" in MySQL.
This occurs when you try to insert a row into a table that exceeds the maximum row size allowed by the server. This can be down to too many columns in the table or by having a single column that exceeds the maximum allowed size. Normally you’d get around this by reducing the size of the data being inserted, or increasing the maximum row size allowed by the MySQL server. Here in Craft, though, that’s not really an option. Aside from ensuring you’re using the smallest column types for Plain Text and Redactor fields, there isn't much you can do without serious data restructuring.
In practice, we’ve found that this issue really only happens when we have a single Matrix or Neo field with a lot of child blocks, and those child blocks have a lot of fields themselves. As it turns out, most of the time there are a few blocks that are only used once and some that are never used at all. Our solution is to change some pages from "Block Builders" to being a little more hardcoded in the template and then just remove the unused blocks (which are usually old and deprecated) after confirming with the client. Finding where and how the blocks are being used has always been the hardest bit... until now...
Introducing Block Usage, which simply shows you how many entries each block (and child block) is used on, from there, you can click through to each block type and see which entries uses it, their entry type, and section.
Block Usage in action on the simplygoodwork.com site
And that's it! We've had to query the DB's manually to find these numbers for a couple of clients recently, so we thought, why not polish this up and ship it for all?
Further reading
-
Craft 5 Released
-
Ten years of Good Work
-
Expanding our services: Introducing ‘Friends of Good Work’
-
How to master GDPR and CCPA compliance: a step-by-step guide to handling website cookies
-
Nag plugin for Craft CMS 3 and 4
-
Three reasons most digital projects get derailed (and why yours doesn’t have to)
-
Good Work leads to a good life
-
Update Craft CMS 3 to 4
-
Three things your project manager should be doing for you (but probably isn’t)
-
Eight lessons learned from eight years of Good Work
-
Putting the puzzle pieces together