Skip to main content
John Brandenburg

Main navigation

  • Home
  • About Me
  • Tech
  • Voting Rights
    • Close Polling Stations:
    • Reject Absentee Ballots
    • 482,000 de-registered voters in Wisconsin since 2016
    • Deceptive Practices by poll workers
    • Gerrymandering
    • Lack of Early Voting
    • Purge Voters
    • Removing Voting Rights from Former Felons
    • Unreliable Voting Equipment
    • Voter ID Laws
User account menu
  • Log in

Breadcrumb

  1. Home

Publishing blocks in Drupal

By John, 23 May, 2025

Blocks have been around for ages in Drupal. In D8, a published status was introduced to allow site admins to show/hide blocks when needed. The problem? The UI to edit this status still isn't available. This is something I had had casually been keeping an eye on for a while, since it is a common use case on websites to want to hide/show blocks when needed. Especially  for things like "Alerts". In the meantime, I've had to hack it by doing things like setting up  custom admin forms with checkboxes that save "states", which feed into a hook_block_access to override the view permission. Or adding the block in config ignore settings - which opens a whole can of works of having your config out of sync with what  you have exported. 

The solution has apparently been right under my nose this whole time. You can set up a Content Moderation workflow on the Block Content entity to allow site admins to edit the publish status of a block. Just remember to check the "Default revision" option when you set up a new unpublished state. Any that's it, that's the post. I can't believe this has been racking my brain for this long, and I'm just now figuring out there is a way to edit that publish status, which has been there all along.

Note, this does only work with "Block Content" blocks, and doesn't work on others like menus, Facets, Lists (Views), Custom or System blocks.

RSS feed
Powered by Drupal