Hi,

If I wanted to edit the Default Login Form, what file would I do this in? Is it in the phptemplate.engine file? All I want to do is edit how it outputs the HTML for it because the way they have it set up, its making it difficult for me to get it to display how I want. Is there a certain function name that I should be looking for? If anyone can help me out I'd really appreciate it.

Joe

Comments

dman’s picture

All I want to do is edit how it outputs the HTML for it

Cool. See the theming guide.

I think you'll want to start with an addition to your template.php

function phptemplate_user_login($form){
  return print_r($form,1);
}

... which is where you'd hijack the display of the user login block for complete control.
It's (FAPI manipulation) a bit scary, but you have to start there to see what drupal_render() would have done to it normally.

function phptemplate_user_login($form){
  return drupal_render($form);
}

There are probably some easier approaches, but it depends exactly what you are changing.

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

micahw156’s picture

This worked well for tweaking a site that uses LDAP authentication against a Novell NDS directory tree. I wanted to remove the site name from the prompts and hard code some other text in its place. I started with dman's example, and found the elements to update by sifting through modules/user/user.module.

Thanks!

<?php
  function phptemplate_user_login($form){
    $form['name']['#description'] = t('Enter your NOVELL username.');
    $form['pass']['#description'] = t('Enter your NOVELL password.');
    return drupal_render($form);
  }
?>
praveen-sl’s picture

this is how i managed it. i wanted to take off descriptions from the text fields and to reduce the width of both username field and the password field.

place this code snippet in the phptemplate file.

function phptemplate_user_login($form) {
  $form['pass']['#description'] = '';
  $form['name']['#description'] = '';
  $form['name']['#size'] = 10;
  $form['pass']['#size'] = 10;
  //A friendlier name for our submit button:
  $form['submit']['#value'] = 'Log in';
	
  return _phptemplate_callback('user_login', array('form' => $form));
}

function  _phptemplate_variables($hook, $vars) {
  global $user;
  switch($hook) {
          case 'page' :
        // SUPER IMPORTANT: These rules prevent you from crashing your server :-)
        if (arg(0) != "user" && $user->uid == "0") {
            $vars['user_login_form'] = user_login($msg = '');
        }
        break;
  }
  return $vars;
}

and then create a file called user_login.tpl.php and then place the following code in that file.

<div id="user_login">
<table width="100%">
	<tr>
		<td width="10%">&nbsp;</td>
		<td class="text1-white" width="30%"><?php print_r(form_render($form['name']));?></td>
		<td class="text1-white" width="30%"><?php print_r(form_render($form['pass']));?></td>
		<td valign="middle" width="30%"><?php print_r(form_render($form));?></td>
	</tr>
	<tr>
		<td colspan="3" align="center" valign="top"><a class="text1-white" href="?q=user/password">Forgot Password</a></td>
	</tr>
</table>
</div>

so now we are set with the customized user login form. if you want to include it in any of the tpl files just print out the variable $user_login_form.

print $user_login_form;

this worked for me. so should work for you too.

--
Praveen Gunasekara
http://rarepraveen.blogspot.com