Search code examples
drupaldrupal-modulesdrupal-hooks

Current context in drupal input filters?


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.


Solution

  • 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