0

Background information: I used the following script to list all the twig blocks: drush ev "print_r(array_keys(\Drupal::service('plugin.manager.block')->getDefinitions()))" and when I tried the following twig : {{ drupal_entity('block', '') }} and it is not rendering the twig block–

I developed a Twig page in Drupal 8 to allow my website visitors the ability to select the language they want. I downloaded all the multilingual contrib modules.

I am facing two issues:

  1. How to render a block in the middle of my twig page to display the language drop-down menu? (I already have a block that displays a drop-down menu language from a contrib module).
  2. The CSS background image I had setup is covering one of the Twig field I wanted to test. How can I tweak the CSS in order to display the twig block?
  • Twig Tweak lets you render blocks in Twig pretty easily. CSS is off-topic. You can't render Drupal blocks with CSS. – leymannx Mar 27 at 16:13
  • I already have twig tweak module installed and enabled. I was just listing two related issues I am facing right now. I am aware that blocks cannot be rendered by Twig. The image I added as a background is just covering the render twig field. – absbennyboy Mar 27 at 16:24
  • I used the following script to list all the twig blocks: drush ev "print_r(array_keys(\Drupal::service('plugin.manager.block')->getDefinitions()));" but I tried the following and it is not rendering the twig block: {{ drupal_entity('block', '<block_id>') }} – absbennyboy Mar 27 at 16:26
  • And why is this info missing from your question? Please update your question and add everything you tried yourself so far. – leymannx Mar 27 at 16:27
0

drupal_entity() is for rendering entities. For rendering block plugins use drupal_block() instead. The difference is explained very well in the following guide. https://www.drupal.org/docs/8/modules/twig-tweak/rendering-blocks-with-twig-tweak

  • thank you for your help. – absbennyboy Apr 1 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.