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.
It would be great if I can combine, <?php ?>
tags, html and tokens.
Comment | File | Size | Author |
---|---|---|---|
#11 | token-support-in-output-code-1317762-D7.patch | 1.12 KB | aoturoa |
Comments
Comment #1
biosonic CreditAttribution: biosonic commented+1
Comment #2
lgammo CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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
tamarackmedia CreditAttribution: tamarackmedia 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 CreditAttribution: 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 CreditAttribution: dariogcode commentedFixed at tag
Comment #11
aoturoa CreditAttribution: aoturoa commentedA simple patch to always replace token strings in the outputted value.
Comment #12
vlooivlerke CreditAttribution: 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