0
votes

I've overridden the drupal front page by creating a page--front.html.twig. In that twig file I want to render the user login block of drupal. I've seached the internet without finding a clear solution to that problem. What I've come to understand is to make that possible I have 2 solutions.

  1. Solution 1: use the hook_preprocess_HOOK()
  2. Solution 2: use a plugin like Twig Tweak

Am I Correct ?

I've tried the 2nd solution by installing twig tweak and inserted the below line in my twig template file
{{ drupal_entity('block', 'block_id') }} with block_id representing the machine name of the block that can be found in the config page.
It displays nothing and that's normal because when I do a {{ kint(drupal_entity('block', 'block_id')) }} to dump the value I got a NULL value.
I don't understand why because I placed the user login form block and configure it to be visible only on the <front> page.

1

1 Answers

1
votes

Twig Tweak

Twig Tweak module provides a Twig extension with some useful functions and filters that can improve developer experience.

Ex: <dd>{{ drupal_view('centers', 'block_1') }}</dd>

hope this help you

THANKS