0

What seems like it should be a very, very simple task -- theming the user login, registration, and password pages in Drupal 7 -- is turning out to be a Kafka-esque nightmare. I can't figure out what I'm doing wrong, and am wondering if I'm slowly regressing into a newt in the process.

So there's a ka-billion how-to posts all over the place about how to do this (all of the posts I've read seem to be derived from this page here), and a ka-trillion success stories, but sadly, I'm not one of them. Here's what I've done, and tell me, please, I beg of you, what idiotic thing I'm doing wrong:

Step 1:

I added the following code to my template.php file, making sure to replace "yourtheme" with the name of my theme:

<?php
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;
}
?>

Step #2:

Then, below that code in the template.php file, I inserted this code, again, making sure to replace "yourtheme" with the name of my theme:

<?php
function yourtheme_preprocess_user_login(&$vars) {
  $vars['intro_text'] = t('This is my awesome login form');
}

function yourtheme_preprocess_user_register_form(&$vars) {
  $vars['intro_text'] = t('This is my super awesome reg form');
}

function yourtheme_preprocess_user_pass(&$vars) {
  $vars['intro_text'] = t('This is my super awesome request new password form');
}
?>

Step #3:

I created three new template files called user-login.tpl.php, user-register-form.tpl.php, and user-pass.tpl.php

Step #4:

I pasted the following code into each new template file:

<p><?php print render($intro_text); ?></p>
<div class="yourtheme-user-login-form-wrapper">
  <?php print drupal_render_children($form) ?>
</div>

I'm slightly confused by this:

"Save your template.php file to the theme's main directory. Save your .tpl.php files in the same place for the D6 examples, or, in the case of the D7 examples, to the directory you specify in the 'path' element of the $items array."

But that just means that I should save the .tpl.php files in my theme directory, correct? If so, I did this correctly.

Step #5:

Cleared the cache, moved around some elements...and...

Nothing. Is there anything I'm doing wrong? Thanks in advance for your help.

0

The template.php file goes into your main theme directory (yourtheme in this instance.) The .tpl.php files go into the templates subdirectory (yourtheme/templates.) If you do not have the subdirectory, create it.

Hope this helps.

0

It is a simple module for Customize Drupal Login, Password and Register pages with background images. https://www.drupal.org/project/simplelogin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.