Pages

Monday, March 22, 2010

How to create customize Region in drupal

We have to define these info in the theme_name.info file.


; $Id: girl.info,v 1.5 2007/07/01 23:27:32 goba Exp $
name = Girl
description = Tableless, recolorable, multi-column, fluid width theme (default).
version = VERSION
core = 6.x
engine = phptemplate
stylesheets[all][] = style.css
stylesheets[print][] = print.css

; Information added by drupal.org packaging script on 2010-03-04
version = "6.16"
project = "drupal"
datestamp = "1267662008"

regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[events] = Events

Customizing and Overriding User Login page, Register, and Password Reset in Drupal 6

Customizing and Overriding User Login page, Register, and Password Reset in Drupal 6

Last modified: August 26, 2009 - 13:22

Customizing the user login, register, and password reset pages is fairly simple, and uses the following concepts:

  • preprocessing to set variables
  • registration of functions in the theme registry
  • creation of one or more theme templates.

Step 1.
In the site theme directory, create or edit your template.php file.

Step 2.
Look for a function named yourtheme_theme() and either modify it to add these return values or if it doesn't exist add the following:

/**
* Registers overrides for various functions.
*
* In this case, overrides three user functions
*/
function yourtheme_theme() {
return array(
'user_login' => array(
'template' => 'user-login',
'arguments' => array('form' => NULL),
),
'user_register' => array(
'template' => 'user-register',
'arguments' => array('form' => NULL),
),
'user_pass' => array(
'template' => 'user-pass',
'arguments' => array('form' => NULL),
),
);
}

Notes about that code:

  • Change the function name by replacing "yourtheme" with the name of your theme
  • The template can be the same for all three. The example above uses a different template for each case: user-login, user-register, and user-pass
  • The template names must use a dash, not an underscore
  • Note: It's user_pass not user_password

Step 3.
Now you implement three preprocess functions. There may be more concise ways to code this, but this works very well and is easy to read, so here we go!

function yourtheme_preprocess_user_login(&$variables) {
$variables['intro_text'] = t('This is my awesome login form');
$variables['rendered'] = drupal_render($variables['form']);
}

function
yourtheme_preprocess_user_register(&$variables) {
$variables['intro_text'] = t('This is my super awesome reg form');
$variables['rendered'] = drupal_render($variables['form']);
}

function
yourtheme_preprocess_user_pass(&$variables) {
$variables['intro_text'] = t('This is my super awesome insane password form');
$variables['rendered'] = drupal_render($variables['form']);
}

Notes about that code:

  • Change the function name by replacing "yourtheme" with the name of your theme
  • The line $variables['intro_text'] adds the text that follows to the $variables array, which gets passed to the template as $intro_text
  • The second line renders the form and adds that code to the $variables array, which gets passed to the template as $rendered

Step 4.
Create template files to match the 'template' values defined above. In this case, we only need two: user-login.tpl.php and user-register.tpl.php (make sure to use a dash, not an underscore)

Step 5.
Paste the following into user-login.tpl.php. Modify as necessary for user-login.tpl.php and user-register.tpl.php:

print $intro_text;




print $rendered;

Step 6.
Save this file to the theme's main directory

Step 7.
Rebuild the cache. Go to Administration > Performance and click on "Rebuild Cache" on the bottom of the page.