How do I theme the login in Drupal 6?

Joined: 10/27/2008

What I'm looking for, is the ability to completely customize the Username/Password fields in Drupal 6. I found an example of the sort of customization I'm looking for on the site www.twoshirts.org, from the www.MustardSeedMedia.com portfolio.

So far, my search has turned up instructions for theming for the Search here:

http://www.codegobbler.com/customizing-search-box-...

But I can't find equivalent instructions for the Login.

G&G Podcast Host
Matt Farina's picture
Joined: 06/01/2006
Shortform

Looking at the code on the twoshirts site that looks to have been accomplished with some CSS and http://drupal.org/project/shortform. Note that shortform is now an abandoned module.

This can, also, be accomplished with some form modifications in your template.php file.

Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com

Matt Farina
Geeks and God Former Co-Host
www.mattfarina.com

Joined: 10/27/2008
I Figured It Out . . . Mostly

Hey Matt,

Thanks for going to the trouble to check out what was used on the twoshirts site.

Since an abandoned module was out of the question, I kept looking around and finally found an article that did an excellent job explaining the necessary template.php code:

http://www.lullabot.com/articles/modifying-forms-5...

(There was even a comment from a "Matt Farina," so I know you were holding out on me.)

Anyhow, the only aspect of customizing the login that still has me stumped, is the ability to put some placeholder asterisks in the password field by default. If anyone has any suggestions for making that possible I'd love to hear them.

And just in case someone ends up here looking for the answer to my original question, but doesn't feel like clicking the link up there, here's the code I put in template.php to make the magic happen:

<?php
function themename_theme() {
  return array(
   
// The form ID.
   
'user_login_block' => array(
     
// Forms always take the form argument.
     
'arguments' => array('form' => NULL),
    ),
  );
}

  function
themename_user_login_block($form) {
   
$output = '';
       
// return print_r($form);
        // Our kickin' mods go here.
       
$form['name']['#title'] = t('Login ID');
       
$form['name']['#value'] = t('Name');
   
$output .= drupal_render($form);
    return
$output;
  }
?>

Of course, replace "themename" with the correct theme name.

Thanks!

G&G Podcast Host
Matt Farina's picture
Joined: 06/01/2006
Saved Passwords

In several browsers if it saves your passwords you will have the asterisk style characters in there for their saved password. Are you looking for something different than that? I would suggest not interfering with that. It would be a pain for some people if password saving stopped working.

Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com

Matt Farina
Geeks and God Former Co-Host
www.mattfarina.com

Joined: 10/27/2008
jQuery To The Rescue

That is an excellent point. I think I have that part of it taken care of though. Again, we can look at the twoshirts approach for what I'm going for here: default values that tell you what go in the box, but disappear on focus. I'm using a script I found here to accomplish that:

http://hocuspokus.net/2008/05/16/default-text-fiel...

It seems to do exactly what I want for the search field, username field and even the password field if—like you say—the browser has a password already stored.

The whole theory here, is to make the login as sleek and unobtrusive as possible, but still have it be clear where the name and password go. I see two modules for Drupal 5 that accomplish this.

Short Form (which you pointed out):
http://drupal.org/project/shortform

Compact Forms:
http://drupal.org/project/compact_forms

G&G Podcast Host
Matt Farina's picture
Joined: 06/01/2006
Accessability

Don't forget accessibility in this mix. :-)

Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com

Matt Farina
Geeks and God Former Co-Host
www.mattfarina.com

Ni
Ni's picture
Hey, I found a good tutorial

Hey, I found a good tutorial here http://www.anupomgogoi.com/how-theme-user-login-fo....