0

I have a custom Login Page in my website

I am using Zen for my themes.

I already have the Login page using the naming convention (e.g xxx--xxxx--tpl.php) but I can't display my form in this page.

here is my cpde

page--user_block--login.tpl.php:

<table class="body_login">
                    <tr>
                        <td class="gre"><div class="green_skin" ></div></td>
                        <td class="gre1"><div class="green_1_skin"></div></td>
                        <td class="cen">
                        <div class="alle" style="width:450px;">
                        <div class="modal-login">
                            <div class="modal-login-header">
                                <p>ONREVUE LOGIN</p>
                                <div class="icon-lock"></div>
                            </div>
                        <div class="content_my">


 /****This is where I want to display the form ***/

</div>
                        </div>
                        <div class="data_d"><p class="other_p"><a href="#">Register</a><span>|</span><a href="#">Forgot Password?</a></p></div> 
                        <div style="clear:both;">
                        </div>
                        </div>
                        </td>
                        <td class="gre1"><div class="green_1_skin"></div></td>
                        <td class="gre"><div class="green_skin"></div></td>
                    </tr>
                </table>  

My Template.php code

function Alphasys_theme(&$existing, $type, $theme, $path) {
$hooks = zen_theme($existing, $type, $theme, $path);
 // Add your theme hooks like this:
/*
  $hooks['hook_name_here'] = array( // Details go here );
*/

$hooks['user_login_block'] = array(
  'arguments' => array('form' => NULL),
       'template' => 'page--user_block--login',
);

 // @TODO: Needs detailed comments. Patches welcome!
 return $hooks;
  }

  function Alphasys_preprocess_user_login_block(&$vars) {
  // Modify the text of the submit button
 $vars['form']['submit']['#value'] = t('Login Now!');

  $vars['form_markup'] = drupal_render($vars['form']);
}

I don't know what's the problem with the Code but it seems I can't make to work...

I already tried to put

<?php echo $form_mackup ?>

in my page--user_block--login but doesn't work.. I already tried to clear the cache.. but it is not working either..

Please help me...Responses are much appreciated..Thanks

1

I think your problem is that you're confusing the login block with the login page in the preprocess function and tpl names

try

function Alphasys_preprocess_user_login(&$variables) {
  //a capitalized theme name?
  $variables['rendered'] = drupal_render($variables['form']);
}

then change the

$hooks['user_login_block']

to

$hooks['user_login']

and drop in your print statement into the tpl

<?php print $rendered ?>

and you should be good to go

3
  • Thanks...I do now figured what's my problem with my code...but I can't see any fields e.g username field, password field when I try to print $rendered in my tpl... 'variables' => array('form' => NULL)...it this the problem ? since I am using Drupal 7 MY question also..is why is it that the form there is null? – Junnel Gallemaso Jul 20 '12 at 5:21
  • Ah, sorry, I'm more familiar with D6 than D7. Looks like others have had this issue, see drupal.org/node/1072294 maybe try changing the hook_theme declaration to use 'render element' rather than 'arguments' and try and print that out? so something like 'render element' => 'form' and <?php print $form ?> . Sorry I can't be more help... – Jay Jul 20 '12 at 14:33
  • also, look to drupal.org/node/1089656 it appears that D7 uses '--' in place of '-', so you could possibly add a page--user.tpl.php along with a page--user--login.tpl.php to get it picked up – Jay Jul 20 '12 at 14:38

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.