Originally from the issue #810190: Let markup field include replacement patterns in value comment #13 (thanks bartclarkson).

I had need for phpcode to return a string that can itself include tokens of other fields defined previously in the view. Putting logic into any .tpl.php file is outside the desired trend, and this should include view override files. The weakness of the $data variable, of itself, is that it doesn't include the finalized style rendering of anything relating to an FID (various filefield-driven output).

Comments

dkingofpa’s picture

Version: 6.x-1.x-dev » 6.x-1.0
Status: Active » Needs work
StatusFileSize
new932 bytes

This patch lets developers use replacement tokens in the value field. This doesn't list the available replacement tokens right below the value field, but you can find those tokens under the "Rewrite the output of this field" section easily enough. Here's an example Customfield: PHP code value:

if (!empty($data->node_data_field_video_asset_field_video_asset_fid)) {
   print '[field_video_asset_thumbnail]';
} else {
    print '[field_video_ftp_fid]';
}

This patch only works for 6.x-1.0. It will safely apply to 6.x-1.x-dev, but doesn't work.

deggertsen’s picture

Fantastic patch! Thank you! I was having the hardest time figuring out what variable to call for a CCK field with a relationship reference, nothing was working. Applied this patch and it worked right away. Definitely should be added to the module.

core44’s picture

Theres now a patch that works with the dev version at the same link. good stuff.

YK85’s picture

Status: Needs work » Needs review

Thank you! This works great.

drupalnesia’s picture

Duplicate? See http://drupal.org/node/972256 -- Enable replacement patterns in PHP code fields

dkingofpa’s picture

Status: Needs review » Closed (duplicate)

Yup, duplicate of #972256: Enable replacement patterns in PHP code fields. I had done my issue queue search using "phpcode replacement" which didn't return the other issue. Dang...could have saved me some time.