I created a new custom block type from /admin/structure/block/block-content/types
having x
and y
fields with field types image and textfield
respectively. Then created a block with the same block type and uploaded image in x
and some text in y
. Here my problem is: how to load this block via code?
More than that how to get values of these block fields x
and y
by loading the block?
I tried these:
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityManager()->getViewBuilder('block_content')->view($block);
but it didn't work.