drupal 输入过滤器中的当前上下文?

发布于 2024-10-02 05:54:59 字数 144 浏览 0 评论 0原文

我想要(需要)编写一个输入过滤器,它将标记替换为当前节点的其他字段(例如图像)的值。我考虑过使用全局变量进行黑客攻击,但也许有一个更干净的解决方案来访问输入过滤器内的当前上下文?

只需使用 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 技术交流群。

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

发布评论

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

评论(1

九局 2024-10-09 05:54:59

据我所知你不能。

过滤器应该只修改接收到的要打印的文本。
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

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