Version 5.4.0
Sites with large Matrix page-builders can make it difficult to know if and when different Matrix blocks are used. This template will give you a report for every Matrix block on your site. It can be filtered by:
- Matrix field
- Block types for that field
- Section, Category, or Global the block type is used on
- Site block is used on (when more than 1 site exists)
- Entry status of parent entry
- Block status
Any entry, category, or global associated with a Matrix block attached will output in this report.
- Copy the template to your craft templates folder. I prefer to keep a sub-folder called
querieswhere I keep utility files like this. - Optional: add these environment variables to your .env file to specify your dev, staging, and prod baseUrls. If omitted it will just build links based off of your current environment url.
MATRIX_REPORT_PROD_URLMATRIX_REPORT_STAGE_URLMATRIX_REPORT_DEV_URL
- Login to your control panel. There is a
requirePermissionconditional in the template so you must be logged in with permissions to access the control panel otherwise it will redirect to your front-end login page. - Go to the url where you placed the template, for me that is https://localsite.test/queries/blocks
If your site runs a CSP in an environment the following items will need whitelisted to allow Alpine and Tailwind to run.
default-src cdn.tailwindcss.com unpkg.comscript-src cdn.tailwindcss.com unpkg.comimg-src unpkg.com
- On Craft 5 it is not reporting nested matrix blocks correctly. The top level block is fine but the child ones need adjusted.
- Sometimes orphan matrix blocks exist on a site even after running
craft utils/prune-orphaned-matrix-blocks. This will cause this template to output an error that gives the ownerId of the orphan. Take that ID and add it to an env namedMATRIX_REPORT_OWNER_FILTER. For multiple values separate with a comma. It should look like:MATRIX_REPORT_OWNER_FILTER=1989,2038
- Fix Craft 5 nested blocks described above
- See if there is a way to provide multi-environment entry urls for multi-site installs (currently it hides the urls in this situation)
- Matrix blocks inside of Neo behave differently and do not output data about the page