drupal 输入过滤器中的当前上下文?
我想要(需要)编写一个输入过滤器,它将标记替换为当前节点的其他字段(例如图像)的值。我考虑过使用全局变量进行黑客攻击,但也许有一个更干净的解决方案来访问输入过滤器内的当前上下文?
只需使用 arg(1) 加载节点即可在节点页面中工作,但在列表中我遇到了麻烦。
I want (need) to write an input filter, which replaces tokens with the values of other fields of the current node (images, for example). I thought about hacking with global variables, but perhaps there is a cleaner solution to access the current context inside a input filter?
Simply loading the node with arg(1) works in node pages, but in lists I'm getting into trouble.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知你不能。
过滤器应该只修改接收到的要打印的文本。
Drupal 开发人员讨论了向
hook_filter
添加更多上下文的可能性,但他们决定避免这样做,因为过于黑客且超出了过滤器操作范围。此外,过滤器不仅用于节点,还用于注释等,因此上下文的管理会更加复杂。
在这种情况下,建议使用
nodeapi
。这是一个讨论(关于drupal 5,但我认为它仍然有效):
http://drupal.org/node/106249
As far as I know you can't.
Filters are supposed to modify only the received text to be printed.
Drupal developers discussed about the possibility to add more context to
hook_filter
but they decide to avoid that because too hackish and beyond the filter action range.Besides, filters are used not only for nodes but also to comments, etc. so the context would have been more complicated to manage.
It is suggested to use
nodeapi
in that case.Here's a discussion (about drupal 5, but I think it's still valid):
http://drupal.org/node/106249