Needs work
Project:
Views PHP
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
22 Oct 2011 at 13:24 UTC
Updated:
8 Feb 2021 at 23:37 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
biosonic commented+1
Comment #2
lgammo commentedYou 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.
Comment #3
bserem commented@lgammo this doesn't seem to work with tokens provided by views in the rewrite section
Comment #4
capellicThe 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
Comment #5
lhugg commentedI 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?Comment #6
lgammo commentedPlease 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.
Comment #7
lgammo commentedFor 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! :-)
Comment #8
elijah lynn#2 appears to work with [site:url] but does not work with something like [counter] if you add a global counter field.
Comment #9
drshearer commentedWhile 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
Comment #10
dariogcode commentedI found this was discussed for the Views Custom Field (antesesor): http://drupal.org/node/1019000, but this wasn't migrated to this version.
Comment #10.0
dariogcode commentedFixed at tag
Comment #11
aoturoa commentedA simple patch to always replace token strings in the outputted value.
Comment #12
vlooivlerke commentedenabling this patch cause the output to get sanitized by xss_admin, this is not desired as it strips html
The token part works great!
Comment #13
liam morland