It would be great if I can combine, <?php ?> tags, html and tokens.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

biosonic’s picture

+1

lgammo’s picture

You can do this.

I just tried this code:
$static = token_replace("[site:url]");

in the setup, value, and output areas. Of course, in the output area you need the print $static;

I hope this helps.

bserem’s picture

@lgammo this doesn't seem to work with tokens provided by views in the rewrite section

capellic’s picture

The solution in #2 doesn't work for me, either.

Looks like they sorted this out in the Drupal 6 version:
http://drupal.org/node/810190#comment-4048824

lhugg’s picture

I can't get any php code to work in the rewrite field, not even a simple print statement. The entire phrase prints out like:
" print "No man is an island";
instead of being evaluated.

Is there ANY documentation for this module? Do we embed the codes or not? A little guidance?

lgammo’s picture

Please check the modules and the versions you have. I have the following modules enabled:
Views 7.x-3.0-rc3,
Display Suite 7.x-1.4,
PHP Filter 7.9,
Views PHP 7.x-1.x-dev,

I think one of the last two modules allows you to setup a view such that it allows you to create a field's value using PHP. When using PHP to create the value you are presented with a form that allows you to create setup PHP code, value PHP code and output PHP code.

I am not sure if this clear. But try to experiment with views. And make sure Display Suite is NOT taking over field display or better still disable it until you know what is going on.

So in sum, create a view (no display suite enabled) add fields, and enable this:
[X] Global: PHP
Use PHP code to construct the output of a field.

Then use my previous posting #2 to get things working.

I hope this helps.

lgammo’s picture

For comments #4, they are using a patch. I think the module combo I am using avoids the patch. Using straight un-patched modules is better in my opinion. IMHO!

Please try the modules I mention in my previous posting and tell me if they work for you.

Enjoy! :-)

Elijah Lynn’s picture

#2 appears to work with [site:url] but does not work with something like [counter] if you add a global counter field.

tamarackmedia’s picture

While I also was unable to use replacement tokens with a custom PHP field in views for D7, I was able to achieve the same result by calling the field value variables in PHP. See instructions on how to do this here:

http://drupal.org/node/1411284

dariogcode’s picture

I found this was discussed for the Views Custom Field (antesesor): http://drupal.org/node/1019000, but this wasn't migrated to this version.

dariogcode’s picture

Issue summary: View changes

Fixed at tag

aoturoa’s picture

A simple patch to always replace token strings in the outputted value.

vlooivlerke’s picture

Status: Active » Needs work

enabling this patch cause the output to get sanitized by xss_admin, this is not desired as it strips html

The token part works great!

Liam Morland’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev