Dear Drupal.org,

I am trying to create a horizontal login for my Drupal powered website (v4.5.2).

The code to make your own login area is:

<?php
          if (empty($edit)) {
            $edit['destination'] = $_GET['q'];
          }
          // NOTE: special care needs to be taken because on pages with forms,
          // such as node and comment submission pages, the $edit variable
          // might already be set.

          $output .= form_hidden('destination', $edit['destination']);
          $output .= form_textfield(t('Username'), 'name', $edit['name'], 15, 64);
          $output .= form_password(t('Password'), 'pass', $pass, 15, 64);
          $output .= form_submit(t('Log in'));
          $output .= "</div>";

          $output  = form($output, 'post', url('user/login'));

        return $output;

?>

Which creates something extacly like the login block by default:

--------------------
|   [=======]    |
|                 |
|   [=======]    |
|                 |
--------------------

I would like to display this login block like:

-------------------------------------
|   [=======]    [=======]           |
-------------------------------------

Any tips?

Comments

rrho’s picture

The easiest way to do this is probably by using CSS. Look at the HTML code you get: the form items are surrounded by DIV tags using the class 'form-item'. You can use 'display: inline' for the class 'form-item' in your CSS file, that should display the form items one beside the other.

Fiddle around with the CSS a bit, it should take you where you want to go.
--
Rochus Wolff - heterocephalusglaber.de

boris mann’s picture

Check the custom login in the PHPTemplate snippets repository.

czarphanguye’s picture

Thank you, very, very much.

Regards,

Czar ['at'] Czarism.com

gopisathya’s picture

See the Action at http://www.ohmybaby.in

Logic:
------
1) Tell your theme to look for new template for login block
2) Create a new login block template file and render the form elements inside that

Step 1 :

Create a file called “user-login-block.tpl.php” in the following directory
“/themes /yourtheme/” .
Step 2:

Put the following code in that file.

      <table width=100%" border="0">
         <tr>
           <td valign="top" width="12%">
             <?php
                print drupal_render($form['name']); 
                // prints the username field
             ?>
           </td>
         <td width="12%">
             <?php
              print drupal_render($form['pass']); // print the password field
             ?>
         </td>
         <td width="12%">
            <?php
               print drupal_render($form['submit']); // print the submit button
            ?>
         </td>
         <td>
            <?php
               print drupal_render($form); //print remaining form elements like "create new account"
            ?>
         </td>
        </tr>
    </table>

You can create your own

tags and place the forms elements there, if you are specific about
tags.

Step 3:

In your template.php add the following function

function zen_classic_theme(&$existing, $type, $theme, $path)
{
return array(
'user_login_block' => array (
'template' => 'user-login-block',
'arguments' => array('form' => NULL)
)
);

}
This is for Zen classic theme . You can change it Like , “ garland_theme ” .
(i.e) “yourtheme name_theme”.

for garland users

function garland_theme()
{
return array(
'user_login_block' => array (
'template' => 'user-login-block',
'arguments' => array('form' => NULL)
)
);

}

SunRhythms’s picture

I am in need of a login bar for Droupal 7 with the latest version of the Zen StarterKit theme...
I could settle just for buttons that just redirected to the logon page and once logged gave a message and a prompt to log out.

But I want to know how to do the horizontal form...

choitz’s picture

Fairly straight forward solution:
http://www.victheme.com/blog/drupal-7-creating-horizontal-login-bar-with...

Both functions go into template.php while print login_bar (); works in page.tpl.php.

Hopefully will stop you having to try various more complex methods.