Since in Drupal 6, the _phptemplate_callback() function is no longer supported, the code snippets on the 'Customising the login form' page at http://drupal.org/node/19855 doesn't work for Drupal 6.

I did some investigating in the new theming changes and came up with a snippet which does work for Drupal 6.

For Step 1 of 2, mentioned on the page, the code which should be added to template.php for Drupal 6.x is :

/**
 * 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() {
  return array(
    'user_login' => array(
      'template' => 'user-login',
      'arguments' => array('form' => NULL),
    ),
  );
}

/**
 * Theme implementation of the user login form.
 * 
 * Drupal 6.x only!
 * Replace 'mytheme' with the name of your theme.
 */
function mytheme_user_login($form) {
  return drupal_render($form);
}

For Step 2 of 2 mentioned on the page, the procedure for Drupal 6.x is exactly the same as for Drupal 5.x.

Hope this helps a bit.

Comments

gdevlugt’s picture

I did some further testing and the code (second function) :

/**
* Theme implementation of the user login form.
* 
* Drupal 6.x only!
* Replace 'mytheme' with the name of your theme.
*/
function mytheme_user_login($form) {
  return drupal_render($form);
}

isn't needed. It was a leftover from some testing. Sorry for the confusion.

dreado’s picture

I can't get this to work, the extra text does not appear. Any idea where I might be going wrong?
Should user-login be user_login btw? I've tried it both ways, still doesn't work.

dreado’s picture

Category: feature » support

... does this only work for the dedicated login page per chance?

gdevlugt’s picture

Hi,

You could try to add the following code to the top of your page.tpl.php file :

<?php drupal_rebuild_theme_registry(); ?>

This will clear out any theme cache left overs preventing things to show up.

The code applies to the dedicated login page.

nikkiana’s picture

Assigned: Unassigned » nikkiana

Working on this at DrupalCon.

nikkiana
knitgeeklife.com

secretz’s picture

function mytheme_theme() {
  return array(
    'user_login_block' => array(
      'template' => 'user_login',
      'arguments' => array('form' => NULL),
    ),
  );
}

will let you change the small login box. And yes, if you use Drupal 5's step 2, you will need to change template's value from 'user-login' to 'user_login'.

Thanks for this, I was struggling with it until now.

revlimiter’s picture

Assigned: nikkiana » Unassigned

Wondering how to modify my Drupal 6.2 Login Form...
I would like to add custom CSS classes to the input fields, add small images above the username and password input fields, and remove the "Username: *" and "Password: *" text.

Any help is greatly appreciated!
Thanks! :)

waldmeister’s picture

Hi!

Ther is a great way to modify internal forms. This puts out a small login form in my header:

function loginform() {
        $loginform=user_login_block();
        $loginform['name']['#size']=15;
        $loginform['name']['#title']="Name";
        $loginform['name']['#description']="";
        $loginform['pass']['#size']=8;
        $loginform['pass']['#title']="Passwort";
        $loginform['pass']['#description']="";
        //print_r($loginform);
        return $loginform;
}

print drupal_get_form('loginform');

I am getting the whole document from drupal and modifying some ugly values.
To see the array and all values, uncomment the print_r
This login Form is always displayed. make your own "User bar" as described here: http://drupal.org/node/92657

Is there an so-called CSS-Guru out there, who can help me out with theming of this?

 <label for="edit-name">Name: <span class="form-required" title="This field is required.">*</span></label>
 <input type="text" maxlength="60" name="name" id="edit-name" size="15" value="" class="form-text required" />

i just don't know how to change the labe-font. tried #edit-name in style.css but doesnt work.

Barry Madore’s picture

Component: Customization and Theming Guide » Correction/Clarification

changing component

davideads’s picture

Assigned: Unassigned » davideads
Status: Active » Needs review

I updated this to reflect Drupal 6 theming techniques and tested them with my custom theme.

However, I think that the structure and form could use work, so I'd love some review here.

There are also seem to be several variations on this theme in the handbook, and probably they should be combined and cleaned up to form a canonical version of this snippet.

davideads’s picture

Status: Needs review » Fixed

I talked with Addy who said just to mark this fixed and move on :)

Eli.’s picture

The file should be "user-login.tpl.php" and not "user_login.tpl.php" (underscore - no no...).

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

lacitpo’s picture

subscribing

holeepassion’s picture

HI there
Where do I find this file ? is it in the user module ?

I want to adjust the length to match the theme, http://www.malebodydecor.com

How do I do this please ?

Thanks

Mick Cagney’s picture

Looking to get rid of the following error:
_____________________________________________________

Access denied
You are not authorized to access this page.
_____________________________________________________

on the landing page. Where could I do this?

jhodgdon’s picture

Mick -- This issue is closed. If you are having trouble with documentation, please open a new issue. If you are having trouble with your own web site, please scroll up to the top of Drupal.org and click on "Community and support" to learn about viable support options: Forums and IRC.