Cms技巧
分享创造价值 合作实现共赢

Cms技巧

当前位置: 首页 > 新闻动态 > Cms技巧

drupal定制用户注册、登录、重置密码页面步骤方

发布时间:2019-12-16 11:16:43作者:admin点击:

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.

The first step is to implement hook_theme for your theme. In the template.php file for your theme, look for a function named yourtheme_theme() and modify it to add these return values. If the function doesn't exist, add the following:

For D6:

代码如下 /**
* 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

For D7:

代码如下 function yourtheme_theme() {
$items = array();
$items['user_login'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'yourtheme') . '/templates',
'template' => 'user-login',
'preprocess functions' => array(
'yourtheme_preprocess_user_login'
),
);
$items['user_register_form'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'yourtheme') . '/templates',
'template' => 'user-register-form',
'preprocess functions' => array(
'yourtheme_preprocess_user_register_form'
),
);
$items['user_pass'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'yourtheme') . '/templates',
'template' => 'user-pass',
'preprocess functions' => array(
'yourtheme_preprocess_user_pass'
),
);
return $items;
}
?>

TOP

QQ客服

18910140161