Normally it is some event that triggers a ruleset. (I hope I have my terminology correct.)
Is it possible to have a menu item trigger the ruleset?
I'll give an example:
Suppose I have a ruleset that accepts as input a node and a user (let's say the objective is to email this user the node (that's just an example, my real use-case is here)). I want to trigger this ruleset by visiting:
example.com/send-node-to-user/234/11
Where 234 is the node's ID and 11 is the user's ID.
(A more useful URL could be "example.com/send-node-to-user/node/234/user/11", to make it possible to figure out what each ID stands for.)
It is possible?
(I mean, possible right now, without me programming it ;-)
If this isn't possible, how else can you achieve the following?
Say we have a view listing some nodes. We want to carry out some action on select nodes. So we put a link on each row, but... we need some URL for the link. (VBO can't help here because we want to pass more than one argument to the ruleset).
Comments
Comment #1
henrijs.seso commentedsubsr. related #914044: trigger flag, cheaters dream
Comment #2
henrijs.seso commentedMaybe this can be fixed by http://drupal.org/project/custom_links module.
Question: can rule be launched with callback? is there a function that can be called with link 'something/rulename/%node/%user/customsomething'?
Comment #3
itangalo commentedI've been thinking about this feature as well, and would like to propose integrating Rules with Page Manager in CTools, or possibly with Panels.
The idea would be to define a path in Page manager, and have Page manager call the rule.
A problem with this is that you eventually would want a page to display, which Rules doesn't really do. You could of course end your rule with a redirect – or have the destination page specified in the configuration in the Page Manager.
However, a neater solution would (IMHO) be to allow rule sets to be called from Panels – where you also could have a number of contexts loaded and sent along as arguments to the set.
Rules configuration in Panels could probably be provided as some sort of plugin and displayed on its own tab in the Panels configuration page.
How about that?
Edit: It seems to me that the original question in this issue can be solved without doing any of the above, and that this issue should be branched off into a new thread.
Comment #4
henrijs.seso commentedi have submitted some patches to custom_link project mentioned in #2 that allows custom rules to be placed in panels and mini panels. so links themselves would be there, complete with token support, anchors, other link properties and permission checking.
So there is no problem creating link like /rules/rulename/%node/%user/somemorearguments and placing it in $links, block or any panel. question is - there needs to be some hook_menu catching that link and executing rule and returning user to previous page if rule does not say differently.
Such two function module could be created - hook_menu + callback function that calls rule. If I knew how to call rule from code with arguments, I could quickly create a module stub. I will have time for that in 2 days.
Comment #5
itangalo commentedFollow up to #3 is here: http://drupal.org/node/543012#comment-3491458
Comment #6
willhowlett commented"It seems to me that the original question in this issue can be solved without doing any of the above"
Is anyone able to explain how this can be achieved? I'm after this exact functionality but for the life of me can't work out how to go about it.
Comment #7
itangalo commented@willhowlett: It is possible to have "a page is going to be viewed" as a triggering event, and then have conditions to check which URL is currently requested. (You will need Rules Bonus Pack if you want to check the URL arguments without using PHP code.)
However, you cannot in this way create a new menu item.
I'll look into how to allow Page manager to trigger rules. That will be for Drupal 7, though. See #1188924: Have Page manager variants to trigger rules
Comment #8
willhowlett commentedThanks for the reply. I've ended up just doing it seperately from Rules with a simple submit button to trigger some php with POST, which suffices for my usage scenario. Still interesting to know what is possible though. Thanks.
Comment #9
itangalo commentedWorking on it right now! Hope to be back with a comment within an hour or two.
Comment #10
itangalo commentedCommitted!
I had to take care of a bug or two, so the demonstration screencast will have to wait. But it is now possible to use Page manager to trigger a rule. Wohoo! (Note: Drupal 7 only. Woho.)
Edit: Quick screencast demo now available at http://vimeo.com/25153525.
Comment #11
mitchell commentedThanks, Itangalo!
Comment #13
mitchell commentedUpdated component.