This patch adds Rules integration. New Rules action is added - "Page redirect (modal forms aware)" which performs page redirect using one of two methods (considering current path):
1. drupal_goto (standard method which Rules module uses)
2. $_GET['destination'] assignment (which must be used inside AJAX handler issued by Modal forms)

Comments

andypost’s picture

Status:Needs review» Needs work
+++ b/modal_forms.info
@@ -2,4 +2,5 @@ name = Modal forms
+files[] = modal_forms.rules.inc

this file does not contains classes

+++ b/modal_forms.rules.inc
@@ -0,0 +1,58 @@
+      $url .= '&';
+      $url .= drupal_http_build_query(drupal_get_destination());

write this with one-line

maximpodorov’s picture

Status:Active» Needs review
StatusFileSize
new2.78 KB

The updated patch.

andypost’s picture

Status:Needs work» Reviewed & tested by the community

Works!

frjo’s picture

Status:Reviewed & tested by the community» Fixed

And now committed to 7-dev. Thanks for the nice contribution and the testing!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

15handsmedia’s picture

How do you use this in rules? I tried but im getting an error that says:
Fatal error: Call to undefined function rules_action_drupal_goto() in /home/content/28/7717728/html/sites/all/modules/modal_forms/modal_forms.rules.inc on line 58

maximpodorov’s picture

Hmm, maybe you're right. Some including of modules/system.eval.inc may be required.

andypost’s picture

Status:Closed (fixed)» Postponed (maintainer needs more info)

@15handsmedia Please explain the steps to reproduce this error

jeroenhoutmeyers’s picture

@andypost I have get the same error cfr. 15handsmedia
Steps: I just added page redirect to modal_forms/nojs/login

maximpodorov’s picture

Status:Postponed (maintainer needs more info)» Needs review
StatusFileSize
new433 bytes

This patch fixes the problem by loading the file which defines the missing function.

andypost’s picture

Status:Needs review» Reviewed & tested by the community

Makes sense

maximpodorov’s picture

Please commit #10, since the problem #6 is still unresolved.

frjo’s picture

Status:Reviewed & tested by the community» Fixed

Committed to 7-dev, thanks for the reminder, and the patch of course.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

areikiera’s picture

Category:feature» bug
Status:Closed (fixed)» Active

This no longer seems to work. Is anyone else having this problem?

Using the following rule:

{ "rules_login_redirect_athlete_coach" : {
    "LABEL" : "Login Redirect",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "modal_forms" ],
    "ON" : { "user_login" : [] },
    "IF" : [
      { "user_has_role" : {
          "account" : [ "account" ],
          "roles" : { "value" : { "23" : "23", "6" : "6" } },
          "operation" : "OR"
        }
      }
    ],
    "DO" : [
      { "modal_forms_aware_redirect" : { "url" : "dashboard" } }
    ]
  }
}
maximpodorov’s picture

areikiera’s picture

Category:bug» feature

Thanks @maximpodorov! I was using the latest dev version, so I've reverted back to 7.x-1.2 + patches from comment #2 and #10, and that works.

areikiera’s picture

Closing again since original feature was addressed/working.

For those just now implementing this feature, I recommend that you don't install the dev version until https://drupal.org/node/2084885 has been resolved. As mentioned before, 7.x-1.2 + patches from comments #2 and $10 will work.

areikiera’s picture

Status:Active» Closed (fixed)

actually closing this time :)

Marko B’s picture

Issue summary:View changes

I wouldn't close still. Seems that with lates dev that commit has been reverted and this patches are added, but I still don't get an opened modal form after the creation of the node. I only get normal redirect and all the code seems fine?! I also use modal forms on other parts of site and they work there.

<?php
{ "rules_after_team_creation" : {
   
"LABEL" : "After Team Creation",
   
"PLUGIN" : "reaction rule",
   
"OWNER" : "rules",
   
"TAGS" : [ "Team" ],
   
"REQUIRES" : [ "rules", "modal_forms" ],
   
"ON" : { "node_insert--team" : { "bundle" : "team" } },
   
"DO" : [
      {
"modal_forms_aware_redirect" : { "url" : "invite-friends", "destination" : 1 } }
    ]
  }
}
?>
Marko B’s picture

I am probably getting this wrong. I was expecting that I can redirect to another modal form, but probably this will only work on redirects from modal page to other normal page.

truyenle’s picture

As #18 mentioned two options. They are both doesn't work for me. After login user is always redirect to front instead of a page that I setup in rule.

But this is working fine if I just go to /user and login not using modal forms.

robriley78’s picture

I can't get this to work. I have the simplest scenario - a modal login window and a rule which says to redirect to the user's profile on login. I've just created the rule using Rules UI - nothing custom. I've applied the 2x patches from #2 and #10 but still doesn't work. Did I miss something?

robriley78’s picture

Ok my bad - for anyone else with the issue, your rule needs to use the Page redirect (modal forms aware) action. The standard Page redirect won't work.

truyenle’s picture

Thank robriley78. It works for me with the dev version of the module that already included patch from #2 and #10.

prsnjtbarman’s picture

It works for me