Posted by jmaines on December 11, 2012 at 5:45am
Can I get a value in a node field in code? I want to use that code to make a decision on how to render an image or to determine which image will be displayed.
Using tokens doesn't work. I tried token_replace and token_scan, but they don't work. The $node variable is not available. $entity doesn't seem to contain node field data and I am not able to create a fully populated node.
I figured it out. I was making a syntax error while accessing $entity. I found it using Devel.
Thanks
Comments
Dynamic field
It sounds very much like a use case for a dynamic field, for which you select a view (assuming you are familiar with Views). Your view should take the id of your node or whatever you are working with as context filter and evaluate your field.
Thanks
I was wasn't using the correct syntax for the $entity object. Thanks to Devel, I was able to figure it out.
Thanks for your help.