I have added the following code:

<?php
function gitb_reviews_menu_alter(&$items) {
 
$items['user/login']['type']             = MENU_CALLBACK;
 
$items['user/login']['modal']           = TRUE;
?>

and the link to the login page now shows up as:

http://itcs2:8082/user/login/nojs

When I click on it, the modal window opens and I get the following Ajax error (see attached file):
-----------------
An AJAX HTTP error occurred.
HTTP Result Code: 404
Debugging information follows.
Path: /user/login/ajax
StatusText: error
ResponseText:
NOT FOUND | IT Central Station
@import url("http://itcs2:8082/modules/system/system.base.css?m711d4");
....
Am I missing something?

Files: 

Comments

Status:Active» Closed (fixed)

The user/login menu item is normally a MENU_DEFAULT_LOCAL_TASK, so it needs a page callback specified...

<?php
function gitb_reviews_menu_alter(&$items) {
 
$items['user/login']['type'] = MENU_CALLBACK;
 
$items['user/login']['page callback'] = 'user_page';
 
$items['user/login']['file'] = 'user.pages.inc';
 
$items['user/login']['path'] = drupal_get_path('module', 'user');
 
$items['user/login']['modal'] = TRUE;
?>

Thanks for the response but that doesn't seem to be the problem.
I added the three lines and I still get the exact same ajax error.

Did you clear your caches?

Also make sure any links you have pointing to /user/login are being turned into /user/login/nojs

I've gotten modal working elsewhere on my site so I'm familiar with how it works.
The links were generated by l() and were /user/login/nojs so I'm sure I cleared the cache. Also I know well enough from experience, :(, that if you change a menu item you need to clear the cache. So yea, I did all that.
The modal popped up, it just gave me the error as displayed in the attached file.

Oops, try without setting 'path'...

<?php
function gitb_reviews_menu_alter(&$items) {
 
$items['user/login']['type'] = MENU_CALLBACK;
 
$items['user/login']['page callback'] = 'user_page';
 
$items['user/login']['file'] = 'user.pages.inc';
 
$items['user/login']['modal'] = TRUE;
?>

That did it. Thank you!

It still doesn't finish the login process but now it's a completely different error and a new investigation.
It seems like the home page data is being returned to Ajax/Javascript, which has no idea what to do with it. What I want is to replacing the whole page. But I will try to figure that one out.

Could you possibly elaborate on why I suddenly had to provide a page callback in my code? Isn't the menu item and therefore 'page callback' already defined by the user module and I am just modifying an existing menu item?

You could try the patch in #1396272: Handle submitted forms. What that will do is either reload the page after the form is submitted, or redirect to a different page if the form has specified a redirect (and the login form usually does).

The reason you had to specify a callback is because the menu item for user/login is normally a default tab. If you look at user_menu() in menu.module, there is no page callback for user/login. With default tabs, if there is no page callback, it gets inherited from the parent - user in this case. CTools Automodal doesn't automagically inherit the page callback like the menu system does, and therefore needs to know exactly which function to call.