Project:Views Custom Field
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:critical
Assigned:Unassigned
Status:active
Issue tags:custom, filter, PHP, replacement, token

Issue Summary

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

Then I could do something like

<?php
return [node-nid] * 10;
?>

Comments

#1

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.

#2

subscribing

#3

Priority:normal» critical

Subscribing

#4

subscribing

#5

Subscribing

#6

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.

#7

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?

#8

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

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