I have created my own theme in drupal 7 using only page.tpl.php as I am happy to use the same template for every node/page.

When visiting mysite.com/?q=user/login every sidebar-navbar from my theme appears there as expected and I would like to remove them from the login form though I really want to avoid creating the login template page--user--login.tpl.php. I was thinking of using the default body class somehow

<body class="html not-front not-logged-in no-sidebars page-user page-user-login"> <body class="maintenance-page in-maintenance no-sidebars">

no-sidebars maybe?


2 Answers 2


The sidebar is appearing as there will be some content(blocks) displayed on it.

So, in blocks section, you need to configure those blocks listed there, and in Show block on specific pages section, select "All pages except those listed" and add user/login in the textarea below.

  • Thank you. In every block I tried selecting All pages except those listed and adding user/login with no results. The sidebar has to have a special <div> id or class? Do I have to follow any rule with the names in the .info file? regions[header] = Header regions[navigation] = Navigation bar regions[sidebar_first] = Sidebar first regions[sidebar_second] = Sidebar second I am using regions[side-menu] = Side Menu regions[navbar] = Navigation Bar regions[content] = Content regions[col2-1] = 2 Columns Number 1 regions[col2-2] = 2 Columns Number 2
    – Joe
    Sep 20, 2016 at 22:51
  • If that doesn't work, why did you accept the answer?
    – Kevin
    Sep 21, 2016 at 13:48
  • Somebody edited my answer
    – Joe
    Sep 22, 2016 at 0:48

I have temporary solved the issue by using a little bit of css to hide the sidebar and, to eliminate the html, the following:

<?php if ($logged_in): ?><div class="mysidebar"></div><?php endif; ?>

I am not sure if there is a way drupal will eliminate the side bar when there is not block on them.

Furthermore, I leave this here so I hope it is helpful to somebody

General utility variables:

  • $base_path: The base URL path of the Drupal installation. At the very least, this will always default to /.
  • $directory: The directory the template is located in, e.g. modules/system or themes/bartik.
  • $is_front: TRUE if the current page is the front page.
  • $logged_in: TRUE if the user is registered and signed in.
  • $is_admin: TRUE if the user has permission to access administration pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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