Hi

I enabled Modal Forms for User Login/Register/Password path, but not working.
When i disable 'Rename Admin Path' module, problem solved.

Anybody can help me, for supporting rename admin path with modal forms?

Thanks.

CommentFileSizeAuthor
#3 modal_forms-2344403-1.patch4.59 KBmahyarsbt
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mahyarsbt’s picture

I have written a quick patch as possible, that resolves this issue.

In 'modal_forms.module' function _modal_forms_doheader() Line 251:

  ...
  // Automatically rewrite selected links to open in a modal.
  if ($GLOBALS['user']->uid == 0) {

  + // Support 'Rename Admin Path' module
  + if (module_exists('rename_admin_paths') && variable_get('rename_user_path', NULL)) {
  +   $settings['rename_path'] = variable_get('rename_user_path_value', 'member');
  +   drupal_add_js(array('ModalForms' => $settings), 'setting');
  + }

    if (variable_get('modal_forms_login', 0)) {
      drupal_add_js($path . '/js/modal_forms_login.js', array('weight' => -20));
    }
    if (variable_get('modal_forms_register', 0)) {
    ...

Changed js files:

modal_forms_login.js

Before

(function ($) {

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

})(jQuery);

After

(function ($) {

Drupal.behaviors.initModalFormsLogin = {
  attach: function (context, settings) {
    var rename_path = Drupal.settings.ModalForms.rename_path;
    if (typeof(rename_path) != "undefined" && rename_path !== null) {
      $("a[href*='/"+rename_path+"/login'], a[href*='?q="+rename_path+"/login']", context).once('init-modal-forms-login', function () {
        var regex = new RegExp(rename_path + "\/login");
        this.href = this.href.replace(regex,'modal_forms/nojs/login');
      }).addClass('ctools-use-modal ctools-modal-modal-popup-small');
    }
    else {
      $("a[href*='/user/login'], a[href*='?q=user/login']", context).once('init-modal-forms-login', function () {
        this.href = this.href.replace(/user\/login/,'modal_forms/nojs/login');
      }).addClass('ctools-use-modal ctools-modal-modal-popup-small');
    }
  }
};

})(jQuery);

modal_forms_register.js

Before

(function ($) {

Drupal.behaviors.initModalFormsRegister = {
  attach: function (context, settings) {
    $("a[href*='/user/register'], a[href*='?q=user/register']", context).once('init-modal-forms-register', function () {
      this.href = this.href.replace(/user\/register/,'modal_forms/nojs/register');
    }).addClass('ctools-use-modal ctools-modal-modal-popup-medium');
  }
};

})(jQuery);

After

(function ($) {

Drupal.behaviors.initModalFormsRegister = {
  attach: function (context, settings) {
    var rename_path = Drupal.settings.ModalForms.rename_path;
    if (typeof(rename_path) != "undefined" && rename_path !== null) {
      $("a[href*='/"+rename_path+"/register'], a[href*='?q="+rename_path+"/register']", context).once('init-modal-forms-register', function () {
        var regex = new RegExp(rename_path + "\/register");
        this.href = this.href.replace(regex,'modal_forms/nojs/register');
      }).addClass('ctools-use-modal ctools-modal-modal-popup-medium');
    }
    else {
      $("a[href*='/user/register'], a[href*='?q=user/register']", context).once('init-modal-forms-register', function () {
        this.href = this.href.replace(/user\/register/,'modal_forms/nojs/register');
      }).addClass('ctools-use-modal ctools-modal-modal-popup-medium');
    }
  }
};

})(jQuery);

modal_forms_password.js

Before

(function ($) {

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

})(jQuery);

After

(function ($) {

Drupal.behaviors.initModalFormsPassword = {
  attach: function (context, settings) {
    var rename_path = Drupal.settings.ModalForms.rename_path;
    if (typeof(rename_path) != "undefined" && rename_path !== null) {
      $("a[href*='/"+rename_path+"/password'], a[href*='?q="+rename_path+"/password']", context).once('init-modal-forms-password', function () {
        var regex = new RegExp(rename_path + "\/password");
        this.href = this.href.replace(regex,'modal_forms/nojs/password');
      }).addClass('ctools-use-modal ctools-modal-modal-popup-small');
    }
    else {
      $("a[href*='/user/password'], a[href*='?q=user/password']", context).once('init-modal-forms-password', function () {
        this.href = this.href.replace(/user\/password/,'modal_forms/nojs/password');
      }).addClass('ctools-use-modal ctools-modal-modal-popup-small');
    }
  }
};

})(jQuery);

I hope it would be desired and useful.

mahyarsbt’s picture

Status: Active » Needs review
mahyarsbt’s picture

FileSize
4.59 KB
Leeteq’s picture