在 Drupal 中捕获块的更改/添加/删除事件
当添加、移动、编辑或删除 Drupal 中的块时,我需要添加一些功能(刷新一些缓存等),是否有任何类型的钩子(或另一种有点 Drupal 本地方式),就像带有 < 的节点一样代码>hook_nodeapi?
我知道有 hook_block
但有 $op
总是 list
,所以它实际上没有任何好处。
I need to add some functionality (flush some caches and such) when a Block in Drupal is added, moved, edited or deleted, is there ANY kind of hook for that (or another somewhat Drupal native way) like there is for nodes with hook_nodeapi
?
I know there is hook_block
but there $op
is always list
, so its not really any good.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,区块没有这种信号机制。我会使用表单系统在您需要额外工作信号的地方添加提交回调。
这种方法的一个缺点是任何配置块的替代方法都不起作用。如果有人在块模块之外构建自定义表单,或者您使用上下文或面板来移动块,则不会有帮助。当然,由于任何这些备用配置点也将使用表单,因此您也可以使用
hook_form_alter()
侵入它们的提交流程。Unfortunately blocks don't have that kind of signalling mechanism. I would use the forms system to add submit callbacks wherever you need a signal for additional work.
The one downside to this method is that any alternate approach to configuring blocks won't work. If someone builds a custom form outside the block module, or if you are using context or panels to move blocks around it won't help. Of course, since any of those alternate configuration points would also use a form, you can use
hook_form_alter()
to hack into their submit processes as well.