I just add this code to drupal documentation page in http://drupal.org/node/478328
paste this in your template.php file in theme directory.
<?php
/**
* This snippet will register a theme implementation of the user login form.
*
* Drupal 6.x only!
* Replace 'mytheme' with the name of your theme.
*/
function MYTHEME_theme(){
'user_login_block' =
> array( 'template' => 'user-login-block',
'arguments' =
> array('form' =
> NULL),
)
);
}
function MYTHEME_preprocess_user_login_block(&$variables) {
// Add a custom placeholder to username field.
$variables['form']['name']['#value'] = $variables['form']['name']['#title'];
$variables['form']['name']['#attributes']['onblur'] = "if (this.value == '') {this.value = '".$variables['form']['name']['#value']."';} ;";
$variables['form']['name']['#attributes']['onfocus'] = "if (this.value == '".$variables['form']['name']['#value']."') {this.value = '';} ;";
// Add a custom placeholder to password field.
// this will not work until you clicked in input, to make this work see <a href="http://drupal.org/node/75225" title="http://drupal.org/node/75225">http://drupal.org/node/75225</a> and apply the patch
$variables['form']['pass']['#value'] = $variables['form']['pass']['#title'];
$variables['form']['pass']['#attributes']['onblur'] = "if (this.value == '') {this.value = '".$variables['form']['pass']['#value']."';} ;";
$variables['form']['pass']['#attributes']['onfocus'] = "if (this.value == '".$variables['form']['pass']['#value']."') {this.value = '';} ;";
// Remove the "Username" & "Password" labels from the form.
unset($variables['form']['name']['#title']);
unset($variables['form']['pass']['#title']);
// Add some classes
$variables['form']['name']['#attributes']['class'] = 'name-field-login-form';
$variables['form']['pass']['#attributes']['class'] = 'pass-field-login-form';
$variables['form']['submit']['#attributes']['class'] = 'submit-field-login-form';
// Change the text on the submit button
//$variables['form']['submit']['#value'] = t('Login');
// Make the submit button (image)
$variables['form']['submit']['#type'] = 'image_button';
$variables['form']['submit']['#src'] =
path_to_theme() .
'/images/login.png';
// Remove links
//unset($variables['form']['links']);
$variables['form']['name']['#required'] = false;
$variables['form']['pass']['#required'] = false;
}
?>
Note that password input will not work (will not get a default value),
See
http://drupal.org/node/75225 and apply the patch
Make a new file "user-login-block.tpl.php" in your theme, and add the following:
<div class="login-form-custom">
<?php print $rendered;
?> </div>
Now clear your theme registry by visiting and saving /admin/build/themes, and your new tpl.php should work.