将 drupal 6 规则模块转换为 drupal 7
规则 2 开发的文档(至少对我来说)似乎比版本 1 更令人困惑。我正在尝试将用户贡献的模块转换为 drupal 7/rules 2 的新规则操作。原始帖子可以在这里找到: http://drupal.org/node/675010#comment-4135238
这是实际操作信息部分,因为看起来 drupal.org 现在已关闭。
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' => 'Node',
);
我的问题
是,这是否需要为 drupal 7 完全重写,或者可以显示代码的快速转换?
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' => 'Node',
);
}
My question is, does this need to be completely rewritten for drupal 7 or can some show a quick conversion of the code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要更改很多内容...
从这里开始:
将“模块”重命名为“组”并将“节点”更改为翻译值,也许是 t('内容') -- 看看是什么规则用于与节点相关的操作。
将“参数”更改为“参数”
删除 eval 输入,该输入已消失。相反,您可能希望将这些键定义为“文本”类型的参数。然后规则将自动为您构建表单,您只需删除表单回调即可。
没有必要,但您可能还想将“命名参数”设置为 TRUE。将带有参数的单个数组作为操作回调函数的键传递,这样当您有许多参数时会更容易。
您可能还需要稍微调整您的操作回调。只需更新 action_info() 挂钩,然后查看传递给回调的规则即可。
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.