I have made neat comment link for anonymous users http://example.com/modal_forms/nojs/login?destination=http://example.com/comment/reply/NID#comment-form
However when I click it then the #comment-form is missing and it's very inconvenient because have to scroll to the comment form, how to fix it?

Here's the code responsible for opening login links in modal window:

Drupal.behaviors.initModalFormsLogin = function (context) { $("a[href*='/user/login'], a[href*='?q=user/login']", context).each(function () { this.href = this.href.replace(/user\/login/, 'modal_forms/nojs/login'); }).addClass('init-modal-forms-login ctools-use-modal ctools-modal-modal-popup-small'); };


Unless you URL encode, the fragment (what you have after the # sign) is not sent to the server.

If you want to include the hash in the destination parameter, it has to be URL encoded.


Note the %23 above. It makes the browser think that the fragment is part of the destination parameter.

  • Thanks alot! Works like a charm, I'll remember that for the future. – drupaluser Oct 23 '15 at 20:54

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.