Project:Custom filter
Version:5.x-1.2
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

$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

#1

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

<?php
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.

#2

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.

#3

Status:fixed» closed (fixed)

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

#4

Title:Get current node id» Get current node ID
nobody click here