Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#3 | data_not_available_d6-2247279-3.patch | 1.08 KB | dhauver |
Comments
Comment #1
haggins CreditAttribution: haggins commentedThere'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.
Comment #2
bismoney CreditAttribution: bismoney commentedI also have a problem. You do not decide?
Comment #3
dhauver CreditAttribution: dhauver as a volunteer commentedThis 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
Comment #4
gumanov CreditAttribution: gumanov commentedHad the same issue - site was upgraded to D7 from D6.
Patch #3 fixed it for me.
Can we get it committed? Thanks!