dmitrig01 puts the login box in a modal window in 156KB

Events happening in the community are now at Drupal community events on www.drupal.org.
dmitrig01's picture

Title says it all...
http://dmitrizone.com/dump/modal_login.mov

[Update: hi all, I'm sorry I haven't been watching this thread]

This is the code:

<?php
/**
* Implementation of hook_menu().
*/
function yourmodule_menu($may_cache) {
 
$items = array();
  global
$user;

  if (!
$may_cache) {
   
$items[] = array(
     
'path' => 'dsc/login',
     
'title' => t('Log in'),
     
'description' => t('Ajax callback'),
     
'callback' => 'dsc_login_page',
     
'access' => $user->uid == 0,
     
'type' => MENU_NORMAL_ITEM,
    );
   
  }
  return
$items;
}

function
yourmodule_login_page() {
  print
drupal_get_form('user_login');
  exit;
}
?>

Make sure to put a link with the class of thickbox that points to dsc/login.

Such as...
<a href="dsc/login" class="thickbox:>Log in</a>

Be sure you have the jQuery thickbox module downloaded and the login block disabled.

Bonus: you can show any form in that syntax. drupal_get_form('user_login'); is the important line. You can change it to anything.

Comments

Sweet.

niklp's picture

Are you going to show us the code for that...? Or am I just stupid... bad playback in VLC :)

Very nice example how to

frjo's picture

Very nice example how to explain something in a simple screencast.

The Thickbox module actually has a built in function to automatically rewrite login links just as you describe in this screeencast.

putting code in theme ?

guardian's picture

cool lesson :)

i have a question though: thickbox module has code that does drupal_get_form("user_login"); while you put this in your own custom module. so far so good, but what is there a place in my theme i could put this function ? so that it's confined to theme specific behavior ?

will be good if we have some

toma's picture

will be good if we have some code

Agreed

emjayess's picture

This shows the hook_menu and the menu callback, but unless someone can lend insights into the mentioned Javascript, the 'thickbox-classing' of the link and the block... this is akin to a spoiled striptease.

I know ninjas like to limit visibility, but... ?

--
matt j. sorenson, g.d.o., d.o.

Help!

sandorcs-gdo's picture

I am asking you write it down for me onto getting out of a step, how I can portray it the modal login form.

I understand the description till now:
Disable the user login block

I do not understand it then, how I have to create it where an access the link.
I do not know it, where it is necessary to write it in the thickbox class.
The href syntax I know it, but I do not understand it where acts this.
I do not understand it, that I have to create a block, or I have to write a new module?
The example code it the thickbox the single copy of a code, you are it it is
necessary to rewrite original one? That full code, you are a part of it only?
The javascript references punctual where it is necessary to write it in?
We my task, if I would like to use it the modal on a panel the new user
formation and the password reminder link?

Please help!