0

I am new to Drupal 8 but not to Drupal ;

In Drupal 8, I enabled the "Login to your account" block in one of my regions : enter image description here

But on the homepage, the block is not showing in the correct region, instead the login form appears in the "Main content" block (but on 404 pages, for instance, it works fine).

Please note that as it is a private website, I disabled the "View published content" for anonymous users, may it be related ? Maybe it triggers the login form in the main content block, thus deactivating the one in the other region ?

How to set up the login form block in the correct region, on my homepage ? Do I have to render the form in a template hook and then pass it to html.twig ou region.twig ?

Thanks in advance for your answers

For the comment reply :

There is nothing fancy with the theme, this is the generic page template, and the theme is quite empty, derivated from the Stable theme, in which I didn't find any noisy tampering. My gues is that the Core is rendering the form, thus hiding the block.

  • Most likely an issue with your templates. (There might be a different page template for the front page/an if statement in your generic page template that is printing these regions on a different position of your markup.) Enable theme debugging, locate the templates in use and check where the banner region is printed. If this wasn't the cause, check if your theme's preprocessing is tampering with the block region blocks. – Mario Steinitz Aug 9 '18 at 13:39
0

Drupal core does not support a good way to have a site that requires the user to log in.

The Require Login contrib module adds this functionality. It also allows for public sections of the site (e.g. a login landing page, links to how to get help, and the like.

| improve this answer | |
0

Digging into the user module, I found out that the function blockAccess inside core/modules/user/src/Plugin/Block/UserLoginBlock.php hides the block on the user.login page. Too bad, I had no homepage defined, so the default page was /user, and so the default route was ... user.login.

I guess I know what to do now: define a proper homepage, which will return a regular "403" that show the block.

Thanks again for your replies.

| improve this answer | |

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.