- Posted on
- • Drupal
Creating custom user login page in Drupal 7
- Author
-
-
- User
- danpros
- Posts by this author
- Posts by this author
-
Maybe sometimes we want a custom style for our Drupal login page, different with the existing default login page in Drupal 7, whether it's for a personal project or client requests.
Here is the simplest way to create a custom login page in Drupal 7.
First open the template.php and add the following code:
function yourthemename_theme() {
$items = array();
// create custom user-login.tpl.php
$items['user_login'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'yourthemename') . '/templates',
'template' => 'user-login',
'preprocess functions' => array(
'yourthemename_preprocess_user_login'
),
);
return $items;
}
Create a new folder "templates" and than creating user-login.tpl.php
file and place it inside.
Open the user-login.tpl.php
file and paste the following code:
<?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']);
?>
Add the wrapper such as div, span, etc. to test it. Don't forget to clear your Drupal cache.