Deactivate matrix blocks per site #10830
-
We have a multilingual site and use a matrix field to build the content of each page with blocks. The blocks are stored in each language. From time to time, however, it would be desirable to disable blocks in individual languages. But this seems not to be possible, blocks are then always deactivated for all languages. Can this be done somehow? Or is it basically not possible? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 15 replies
-
That’s currently not possible, however you could pull it off by adding a custom “Enabled for site” Lightswitch field to each block type (defaults to enabled), and set it to be translatable for each site. Then when querying Matrix blocks, only fetch the ones where that field is enabled: {% set blocks = entry.myMatrixField
.myEnabledForSiteHandle(true)
.all() %} |
Beta Was this translation helpful? Give feedback.
-
@brandonkelly Sorry for my late reply, but I'm a little lost here right now. We get our content via GraphQL and it doesn't seem possible to filter the MatrixBlocks accordingly. Our query looks something like this:
which results in the following error:
It works without the inline fragment |
Beta Was this translation helpful? Give feedback.
That’s currently not possible, however you could pull it off by adding a custom “Enabled for site” Lightswitch field to each block type (defaults to enabled), and set it to be translatable for each site.
Then when querying Matrix blocks, only fetch the ones where that field is enabled: