tags:

views:

809

answers:

2

What do I call my override function in template.php?

themename_user_login_block() ???

I need to alter this line: $output .= drupal_get_form('user_login_block');

to something like this: $output .= drupal_get_form('themename_user_login_block');

Thx, John

A: 

What you're probably looking for is hook_form_alter() (or its cousin hook_form_FORM_ID_alter()) if you want to make significant changes to the form itself - this keeps all the default form processing for the form (such as actually logging people in) in place and lets you add some of your own functionality if need be. The downside is that these need to reside in modules, not the theme layer.

If you're just looking to change how it looks, I just read a blog post off the Drupal.org aggregator that details theming the login block and how to go about manipulating purely inside the theme layer.

Sean McSomething
hook_form_alter() can be bypassedin the theme layer with THEMENAME_user_login_block()
John
A: 

My solution:

function THEMNAME_user_bar() { 
  global $user;
  $output = "";
  if (!$user->uid) {
    $form = drupal_get_form('THEMENAME_user_login_block');
    $form = str_replace("*","",$form);
    $form = str_replace("Username:","Username",$form);
    $form = str_replace("Password:","Password",$form);
    $form = str_replace('input type="submit"','input type="image" src="/sites/all/themes/THEMENAME/images/login-submit.png" ',$form); 
  }
  $output .= $form;
  return $output
}

works great

John

related questions