Template for user login, registration and password pages

lmonaco99 - December 8, 2008 - 17:00

Hi
I am using version 5.9 and am not able to get Drupal to see or use my custom template files, It seems to be ignoring my instructions to use another
I have already read most of the instructional posts on this topic such as
http://drupal.org/node/154113, http://www.nicklewis.org/node/845, etc and have followed the instructions, and yet it doesnt work.

Can any one help?

Here is what ive done:
Updated bluebreeze/template.php:

function _phptemplate_variables($hook, $vars = array()) {
global $user;
switch ($hook) {
case 'node':
// Here is the way to switch to a different node- template based on node properties.
if ($vars['page']) {
// This is LIFO (Last In First Out) so put them in reverse order, i.e
// most important last.
$vars['template_files'] = array('node-default-page', 'node-'. $vars['node']->type .'-page', 'node-'. $vars['node']->nid .'-page');
}
else {
$vars['template_files'] = array('node-'. $vars['node']->nid);
}
break;

case 'page':
if (arg(0) == 'user'){
if (!$user->uid) { //check to see if the user is logged in. If not display the special login page layout
if (arg(1) == 'password' ) {
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!THIS IS PRINTING SUCCESSFULLY!!!!! print "E";
// the template i wish to use is themes/bluebreeze/user-password.tpl.php
$variables['template_file'] = 'user-password';

}else{
print " Arg 1=".arg(1);
}
}
elseif (arg(1) == 'login' || arg(1) == 'password' ) {
$variables['template_file'] = 'user_login';
}
}
break;
}

return $vars;
}

Thanks in advance!!
luke

Hi Guys - I just figured out

lmonaco99 - December 8, 2008 - 17:18

Hi Guys -
I just figured out the MAIN issue: i was using "$variables" and "$vars" in the above function(YES IM AN IDIOT).
here is the fixed block of code:

if (arg(1) == 'password' ) {
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!THIS IS PRINTING SUCCESSFULLY!!!!! print "E";
// the template i wish to use is themes/bluebreeze/user-password.tpl.php
$vars['template_file'] = 'user-password';
}

OK next issue:
On the template page, this code is displaying nothing:

echo drupal_render($form);

what should i be using to rrender the form?
thanks again!

You're getting

pobster - December 8, 2008 - 17:23

You're getting confused...

See here you're referencing $vars;

function _phptemplate_variables($hook, $vars = array()) {

Yet you're attempting to add variables into $variables['template_file'] = 'user-password'; when it should be $vars['template_file'] = 'user-password';. See at the end return $vars; you're returning $vars here as well...

edit: echo drupal_render($form); this means nothing in a tpl file unless you're theming a form, this is the reason you're creating variables in the first place... Just read the handbook there's awesome docs on this...

Pobster

 
 

Drupal is a registered trademark of Dries Buytaert.