- Issue created by @nojj
- πΊπΈUnited States freelock Seattle
I think what you're looking for is not block "access", but rather a "condition" plugin. This section of the manage block display shows core condition plugins that control block visibility.
As I understand it, we could implement entity access for "content_block" entities that might allow you to show/hide blocks anywhere they appear -- but this would only apply to content_block entities, not any other type of block, or custom block plugins, or anything else.
To control whether or not a block appears on a particular page, there are several different ways of showing blocks -- the core block system (which uses condition plugins), Layout Builder (which currently doesn't have any way to add conditions), Context, Display Suite, Panels, Twig Tweak, Ctools... Each of these has its own way of controlling whether or not to show a block.
- π©πͺGermany jurgenhaas Gottmadingen
It seems that in addition to the block conditions, there is also the
hook_block_access
with this documentation:* Control access to a block instance. * * Modules may implement this hook if they want to have a say in whether or not * a given user has access to perform a given operation on a block instance.
That really sounds as if we could use that hook, turn it into an event and override the access control for a specific block.
- π©πͺGermany mxh Offenburg
It's already possible with eca_access. Attached an example model that denies access on the site branding block used in the Olivero theme.
Thanks @mxh
there is a litte typo typo in the filename: tar_.gz
but it is a great help and indeed, it is possibly to show/hide blocks witheca_access
.maybe using
hook_block_access
would be a little bit more flexible, aseca_access
can only react onECA Access events.
https://ecaguide.org/plugins/eca/access/actions/eca_access_set_result/- π©πͺGermany mxh Offenburg
there is a litte typo typo in the filename: tar_.gz
That's on purpose for security reasons. d.o. automatically renames the file endings when uploading archives.
maybe using hook_block_access would be a little bit more flexible, as eca_access can only react on ECA Access events.
Could you please elaborate what you're currently missing?
hook_block_access
is a variant ofhook_ENTITY_TYPE_access
forblock
config entities. Theeca_access
module reacts uponhook_entity_access
, i.e. it is basically already reacting upon that hook. for my intention, I am not missing anything right now.
"maybe" was meant more as a possible improvement - I haven't checked this. the thought just came to my mind. if the two hooks are more or or less the same, then so be it.
- Status changed to Fixed
9 months ago 8:21am 26 April 2024 Automatically closed - issue fixed for 2 weeks with no activity.