Customizing the "user account' title for register/login pages
January 30, 2008 - 8:25am
Step 1 of 2
- make a copy of your page.tpl.php file and rename it to be page-login.tpl.php.
- Using a text editor like notepad.exe or equivalent, modify the layout of page-login.tpl.php file to suit your desires
- Upload your new page-login.tpl.php layout file to your active theme folder
Step 2 of 2
- Using a text editor like notepad.exe or equivalent, paste the snippet below into your template.php file.
- Upload your edited template.php file to your active theme folder and your new layouts will take effect automatically
<?php
/**
* This snippet loads a custom page-login.tpl.php layout file when
* users click through to the login, request password or register pages
*/ function _phptemplate_variables($hook, $variables = array()) {
switch ($hook) {
case 'page':
global $user;
if (arg(0) == 'user'){
if (!$user->uid) { //check to see if the user is logged in. If not display the special login page layout
$vars['template_file'] = 'page-login';
}
elseif (arg(1) == 'login' || arg(1) == 'register' || arg(1) == 'password' ) {
$vars['template_file'] = 'page-login';
}
}
break;
}
}
?>
/**
* This snippet loads a custom page-login.tpl.php layout file when
* users click through to the login, request password or register pages
*/ function _phptemplate_variables($hook, $variables = array()) {
switch ($hook) {
case 'page':
global $user;
if (arg(0) == 'user'){
if (!$user->uid) { //check to see if the user is logged in. If not display the special login page layout
$vars['template_file'] = 'page-login';
}
elseif (arg(1) == 'login' || arg(1) == 'register' || arg(1) == 'password' ) {
$vars['template_file'] = 'page-login';
}
}
break;
}
return
$variables;}
?>
In page.tpl.php, in place of:
<h1 class="title"><?php print $title ?></h1>
Insert:
<h1 class="title">
<?php if (arg(0) == 'user' && arg(1) == 'register') : ?>
Create an Account
<?php elseif (arg(0) == 'user' && arg(1) == 'password') : ?>
Retrieve lost password
<?php elseif (arg(0) == 'user' && arg(1) == 'login') : ?>
User Login
<?php elseif (arg(0) == 'user') : ?>
User Account
<?php else : ?>
<?php print $title ?>
<?php endif ; ?>
</h1>
<?php if (arg(0) == 'user' && arg(1) == 'register') : ?>
Create an Account
<?php elseif (arg(0) == 'user' && arg(1) == 'password') : ?>
Retrieve lost password
<?php elseif (arg(0) == 'user' && arg(1) == 'login') : ?>
User Login
<?php elseif (arg(0) == 'user') : ?>
User Account
<?php else : ?>
<?php print $title ?>
<?php endif ; ?>
</h1>





