I tried to create a custom node token:

Machine name: test
Type: node

PHP-Code:

dpm($data);
dpm('Hello World');

return 'test';

Test:

$node = node_load(123);
$text = '[node:test]';
$result = token_replace($text, array('node' => $node));

This always prints me "Hello World" and never the contents of $data. I also can't access $data['node'] directly - thous it's not available.
Tested with dev and current release.

Any ideas?

CommentFileSizeAuthor
#3 data_not_available_d6-2247279-3.patch1.08 KBdhauver
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

haggins’s picture

There's the following issue:

The module looks if the format is "php_code". That's what I selected. However, the format is '2' instead of "php_code"...

If I do a filter_format_load(2) I get the filter format array which contains as name "PHP code". But there's no machine readable name indicating whether this is a php format or not.

I'm confused, don't you have the same problem?

edit: someone changed the formats machine names to 1, 2, 3, 4. Anyway, it would be nice if there was way to recognize whether the choosen format contains the php filter or not instead of relying to default machine names.

bismoney’s picture

I also have a problem. You do not decide?

dhauver’s picture

This problem can occur when this module is used with sites that have been upgraded from Drupal 6. The machine names for Drupal 7 text formats use meaningful values such as php_code. However, the machine names for Drupal 6 text formats are numeric. Sites that have been upgraded from Drupal 6 will continue to use the numeric identifiers.

I have attached a patch for the 7.x-2.x branch that I believe should fix the issue. It is based upon the solution for a similar problem with the Chaos Tools suite. See https://www.drupal.org/node/525538#comment-1839528

gumanov’s picture

Had the same issue - site was upgraded to D7 from D6.
Patch #3 fixed it for me.
Can we get it committed? Thanks!