The documentation for rules 2 development seems (to me at least) a lot more confusing than version 1. Im trying to get a user contributed module for a new rules action converted over to drupal 7/rules 2. The original post can be found here: http://drupal.org/node/675010#comment-4135238
Here is the actual action info part since it looks like drupal.org is down right now.
function paction_rules_action_info() {
return array(
'paction_mail_node' => array(
'label' => t('Send node as HTML formated email'),
'arguments' => array(
'node' => array('type' => 'node', 'label' => t('Content')),
),
'eval input' => array('to', 'from', 'subject', 'message'),
),
'module' =开发者_JAVA技巧> 'Node',
);
}
My question is, does this need to be completely rewritten for drupal 7 or can some show a quick conversion of the code?
You will need to change quite a few things...
Start with this:
Rename 'module' to 'group' and change 'Node' to a translated value, maybe t('Content') -- Have a look what Rules uses for Node related actions.
Change 'arguments' to 'parameter'
Drop eval input, that is gone. Instead, you probably want to define these keys as parameters of type 'text'. Then rules will automatically build the form for you and you can simply remove your form callback.
Not necessary, but you might want to also set 'named parameter' to TRUE. That passes a single array with the parameters as keys to your action callback function, makes it easier when you have many parameters.
You might need to adapt your action callback a bit too. Just update the action_info() hook and then look at what rules is passing to your callback.
精彩评论