How can I get the node ID, that will be post after the filter processing $text ,in a filter module?

Thanks a lot.

Comments

lllkkk’s picture

I am a little new at this so bare with me...:
Does anyone can give some suggestion, or just a link?

frjo’s picture

I too would like to know if this is possible. I would like to implement the inline module as a true filter but I need this function first.

profix898’s picture

I dont think its possible at the moment. Look at the code to invoke
filters. It does not pass $node to the filter function. But I agree this
would be very helpful! Maybe for 4.8 or later, we can change the
parameters.

fjen’s picture

if (arg(0) == 'node' && is_numeric(arg(1))) {
          $node = node_load(array('nid' => arg(1)));
}
lllkkk’s picture

I mean get nid in hook_filter , this code doesnot work

----------------------------------------------
my drupal site http://www.kylinx.net/

borazslo’s picture

The same question, but Drupal 6.x: http://drupal.org/node/239737

jordojuice’s picture

Yeah D4 is long unsupported, but on of my modules does this. I think the best way is this:

if ($node = menu_get_object()) {
  // Do stuff.
}

This ensures that the node object is accessible in most situations where filters are being used on node text, and your code is just skipped otherwise. I think menu_get_object() is very useful for this.

Check out the API docs for more information on how you can make use of the function. http://api.drupal.org/api/drupal/includes--menu.inc/function/menu_get_ob...