0

I'm trying to customize the login form. I added this to my template.php

function neptune_theme() {
  $items = array();
  $items['user_login'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'neptune') ,
    'template' => 'user-login',
    'preprocess functions' => array(
       'neptune_preprocess_user_login'
    ),
  );
  return $items;
}

and this is my user-login.tpl.php

<p><?php print render($intro_text); ?></p>
<div class="user-login">
  <?php print drupal_render_children($form) ?>
     <div class="links">
    <a href="/user/register">Create an Account</a> | <a href="/user/password">Forgot Password</a>
  </div>
</div>

I wanna know how to show the username, password and submit fields separately in the user-login.tpl.php file. I want to put the links for "Create an account" and "Forgot your password" before the Submit button.

I want to show something like


|Username |



|Password |


Create an Account | Forgot your password


|Submit|


Thank You. I hope it makes sense. :)

0

You can create a user login template. In your theme file, put this function in and replace your_themename with the machine name of your theme.

function your_themename_theme() {
  $items = array();
  $items['user_login'] = array(
  'render element' => 'form',
  'path' => drupal_get_path('theme', 'your_themename') . '/templates',
  'template' => 'user-login',
  'preprocess functions' => array(
  'your_themename_preprocess_user_login'
  ),
 );
return $items;
}

Then, you can split the individual fields of the form up in a template file called user-login.tpl.php and rearrange them however you want.

<?php
    print drupal_render($form['name']);
    print drupal_render($form['pass']);
    print drupal_render($form['form_build_id']);
    print drupal_render($form['form_id']);
    print drupal_render($form['actions']);
?>

Source: High Rock Media

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.