I made a custom block in my custom module. I now want to show that block in the "No results" area of a view, but I can't get it to render (I don't see any error message, and I don't see any output).
Here is the block definition:
/**
* Provides an 'New User' Block.
*
* @Block(
* id = "newuser_block",
* admin_label = @Translation("New user block"),
* category = @Translation("MYMODULE"),
* )
*
In my view, in the "No results" section, I added Rendered entity - Block, and set the Block ID to newuser_block.
However, the block does not get rendered.
This is because I did not add the block on the block admin page at /admin/structure/block
. When I add the block on the admin page and use the admin page block ID (not the block machine name), the block is rendered correctly.
However, I don't want to add the block to the admin page because I only need this block in a few places on my site, so I was using Layout Builder to inject the block where necessary.
So, is there a way to inject a block by machine name (instead of by the ID used on the block admin page) in Views?