Horizontal Login Block?

czarphanguye - April 10, 2005 - 22:31

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?

The easiest way to do this

rrho - April 10, 2005 - 23:25

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

Check the custom login in

Boris Mann - April 11, 2005 - 01:34

Check the custom login in the PHPTemplate snippets repository.

Thank you, very, very

czarphanguye - April 11, 2005 - 03:22

Thank you, very, very much.

Regards,

Czar ['at'] Czarism.com

Horizontal login bar for Drupal6

gopisathya - September 7, 2009 - 17:03

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)
)
);

}

 
 

Drupal is a registered trademark of Dries Buytaert.