$node->nid doesn't appear to be available in the php-code section of the filter. What do you suppose is the best way of getting the nid for the current node? (Might want to reassign this as a feature request)

Awesome module by the way, a real gem.

Comments

arhip’s picture

Hi,

Filters are processed before node object loaded, that's why we couldn't merely use $node object. See issue #229936: Date issue in php-enabled custom filter for details. There a patch in comment #2, or you can copy and paste this code to your customfilter.module


function customfilter_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  global $_customfilter_code_vars;

  if ($op == 'load') {
    $_customfilter_code_vars->node = $node;
  }
}

In the filter's code, use $vars->node->nid to get the node's nid, or $vars->node to get node object. This patch forces drupal to load node before the filter get processed.

Hope it helps.

Thanks for your kind words.

avpaderno’s picture

Status: Active » Fixed

I am setting this support request as fixed because it got an answer. The reported code is the one used in the 6.x-2 branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

avpaderno’s picture

Title: Get current node id » Get current node ID