I am looking for a way to trigger a rule when clicking on a link. What I am actually trying to do, is fireing a VBO with a Button, instead of the Dropdown solution. For this, I created a Rules-Component that does the job, but I don't know how to fire that rule, as it should start from within a view.
3 Answers
take a look at Rules Link:
This module lets you create links which trigger arbitrary functionality with the help of Rules.
First of all, rules components cannot be triggered on their own. You will need to create a rule for that that will be triggered when one event occurs. Then you should write some code. I would do it like this:
- have a custom page in your module (Eg: "actions/my-custom-rule")
- trigger the rule using
rules_invoke_event('the_event', $params);
- redirect the user back to the previous page using
drupal_goto(drupal_get_destination());
If the event is something custom, you need to define the event in your module. Find out more about integrating rules in your module from here.
-
Thanks for that info. Then I missunderstood rules. When I do have my own implementation in a custom module I can do the action there without rules anyway.– AndiSep 16, 2014 at 13:50
I am looking for a way to trigger a rule when clicking on a link.
This is answered correctly by @geoff
What I am actually trying to do, is fireing a VBO with a Button, instead of the Dropdown solution. For this, I created a Rules-Component that does the job, but I don't know how to fire that rule, as it should start from within a view.
This is a setting in the views panel. Click the field "Views bulk operations" and select to expose each component as a separate button instead of a droplist under "Bulk operations settings".