Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have added the following code:
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?
Comment | File | Size | Author |
---|---|---|---|
Screen Shot 2012-07-11 at 11.06.55 PM.png | 145.81 KB | nafmarcus |
Comments
Comment #1
milesw CreditAttribution: milesw commentedThe user/login menu item is normally a MENU_DEFAULT_LOCAL_TASK, so it needs a page callback specified...
Comment #2
nafmarcus CreditAttribution: nafmarcus commentedThanks 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.
Comment #3
milesw CreditAttribution: milesw commentedDid you clear your caches?
Comment #4
milesw CreditAttribution: milesw commentedAlso make sure any links you have pointing to /user/login are being turned into /user/login/nojs
Comment #5
nafmarcus CreditAttribution: nafmarcus commentedI'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.
Comment #6
milesw CreditAttribution: milesw commentedOops, try without setting 'path'...
Comment #7
nafmarcus CreditAttribution: nafmarcus commentedThat 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?
Comment #8
milesw CreditAttribution: milesw commentedYou 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 atuser_menu()
inmenu.module
, there is no page callback foruser/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.