Pages

Sunday, February 14, 2010

Creating the Login Form in the Horizontal Way +DRUPAL

Some of the time we want to have a LOGIN FORM in the HORIZONTAL WAY. I am sure we will first striking our brain with the word...CSS. Of course we can do it. But Drupal its self have the way to do so why don't  we crack it. For example see the sample site : http://www.ohmybaby.in/  Here you will see the login form in the horizontal way. Here we need to tell our theme to look for new template for login block. For that we need to create a new login block template file and render the form elements inside that. Follow the steps:-


Step 1 :
Create a file called “user-login-block.tpl.php” in the following directory


Step 2:
Put the following code in that file.


print drupal_render($form['name']); // prints the username field
?>

print drupal_render($form['pass']); // print the password field
?>

print drupal_render($form['submit']); // print the submit button
?>

print drupal_render($form); //print remaining form elements like "create new account"
?>

You can create your own tags and place the forms elements there, if you are specific about tags.


Step 3:
In your template.php add the following function:-
function zen_classic_theme(&$existing, $type, $theme, $path)
{
return array(
'user_login_block' => array (
'template' => 'user-login-block',
'arguments' => array('form' => NULL)
)
);
}
This is for Zen classic theme . You can change it Like , “ garland_theme ” .
(i.e) “yourtheme name_theme”.
for garland users
function garland_theme()
{
return array(
'user_login_block' => array (
'template' => 'user-login-block',
'arguments' => array('form' => NULL)
)
);
}

No comments:

Post a Comment