It would be great if you could add support for tokens before the PHP-code is executed.

Then I could do something like

return [node-nid] * 10;

Comments

Daniele Testa’s picture

I know that I can use this module for markup mode:

http://drupal.org/project/token_filter

But then I do not have access to the $data variable or the views attributes.

Bilmar’s picture

subscribing

harking’s picture

Priority: Normal » Critical

Subscribing

John Bryan’s picture

subscribing

Isostar’s picture

Subscribing

intyms’s picture

you can use http://drupal.org/project/token_filter
together with php function:

$your_text_filtered = check_markup($your_text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE);

see filter.module from "modules/filter" directory to find more information about check_markup() function.

ps. do not forget to add Token Filter to your Default Input Format.

TechNikh’s picture

Issue tags: +PHP, +filter, +token, +replacement, +custom

token_filter worked for this case

$your_text = "[token global site-name]";
$your_text_filtered = check_markup($your_text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE);
print $your_text_filtered;

token_filter still doesn't support all tokens especially node tokens. I don't know if it can get the replacement patterns for the fields.
My use case: I have a voting widget in views field. I excluded it. Now I want to put a custom php field and show the voting widget within

if the node is published and within

if node is unpublished.

Any alternatives for my case?

TechNikh’s picture

This worked like a charm. http://drupal.org/node/972256#comment-4172446

<?php
print '<div class="signup-status-[status]">[buyitnowbutton]</div>' ;
?>