I am having a problem with my custom blocks rendering, and I want to programmatically manipulate the blocks to troubleshoot the issue.
I used this question to add this hook to my module:
function mymodule_block_view_alter(array &$build, Drupal\Core\Block\BlockPluginInterface $block) {
drupal_set_message($block->getBaseId());
}
However, when I navigate to my site, I see only the base ids of system blocks:
- page_title_block
- system_main_block
- help_block
- local_tasks_block
My site's header and footer are made of custom blocks, so I should be seeing their ids.
How can I programmatically access my custom blocks?
Edit this is my actual code:
$ cat my_block_hooks.module
<?php
function my_block_hooks_block_view_alter(array &$build, Drupal\Core\Block\BlockPluginInterface $block) {
drupal_set_message(__FUNCTION__ . "() id: " . $block->getBaseId() );
}
And here's a screenshot:
You can see that all the system blocks show up, but my custom block does not.
This is the custom block as I have it set up:
And here I have it placed in the layout:
And of course, I've cleared the cache many times to get to this point.
What am I doing wrong?