How to load a block programmatically and use in twig file
Add the following code in right preprocess in the .theme file.
$block =
Block::load('test_block');
$variables['test_block'] =
\Drupal::entityTypeManager()
->getViewBuilder('block')
->view($block);
Now in your twig file you print test block
in following way {{ test_block }}.
Comments
Post a Comment