I have created a custom block of id downloadourapp
and I would like to show/hide it base on certain statements.
I have create my custom module along with .module
file where the code should be, however, I failed to find the right function to be used for that matter.
is hook_block_view_alter
is the right function and how to hide or show this downloadourapp
specific block.
return AccessResult::forbidden()->addCa....
return AccessResult::forbidden()->addCacheableDependency($block);
worked for me but the problem lies underif ($block->getPluginId() == 'downloadourapp') {
because when I remove this line,downloadourapp
block is hidden for good along with all other blocks. Note: I am sure the block id isdownloadourapp
as taken from the block edit url/admin/structure/block/manage/downloadourapp
but why it not being respected in code ?if ($block->id() = 'downloadourapp') {