如何在保存之前更新节点(书籍或页面)而不触及 Drupal 中的模块代码?

发布于 2024-09-01 20:58:05 字数 111 浏览 3 评论 0原文

我想在实际将数据写入数据库之前在节点中设置一些值。我已经通过修改 book_nodeapi 使其工作,但我想从代码外部执行此操作,一些允许我保持模块代码不变的 _alter 选项会很棒。

谢谢

I would like to set some values in the node before actually writing the data to the DB. I already have it working by modifying book_nodeapi but I would like to do it from outside the code, some _alter option that allows me to leave the module code untouched would be great.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

落墨 2024-09-08 20:58:05

您可以创建自定义模块并实现 hook_nodeapi (mymodule_nodeapi) 就像 book 模块一样。每个活动模块都有机会连接到所有节点的nodeapi。

You can make a custom module and implement hook_nodeapi (mymodule_nodeapi) in it just as the book module does. Every active module gets a chance to hook into nodeapi for all nodes.

太阳哥哥 2024-09-08 20:58:05

如果我了解您的需求,规则模块在此类任务中非常有用。
您所需要做的就是根据所需的内容类型创建条件,并执行设置值的操作。
可以使用静态值、Token 值甚至 PHP 代码来设置该值。

此处是一个包含规则基础知识的截屏视频。

If I understand what you need, Rules module can be very useful in such tasks.
All you need to do is to create a condition according to the content type you want, and to have an action that sets the value.
Setting the value can be done using static values, Token values, or even PHP code.

Here is a screencast with Rules basics.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文