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.
By jag339 on
Hi,
I have a custom type with an Integer field. I have a view to display that field. For whatever reason, when I try to access that field using the global php available fields, what gets returned is not the field value itself, but instead the node id.
What the heck??
Has this happened to anybody else?
Comments
What does your code look
What does your code look like?
Situation update... Followed
Situation update...
Followed the advice given here: http://blog.cvrc.virginia.edu/?q=node/13.
Did a
print_r($data);
Got a whole bunch of output.
The field I want output like this: [field_myfield] => Array ( [und] => Array ( [0] => Array ( [value] => 1 ) ) )
So I test it like this just to see what prints, but no value renders:
Try using print instead of
Try using print instead of print_r
Didn't work.
Didn't work.
Looking at the project
Looking at the project documentation I think you need to return (not print) the value
Which field was code entered
The code you tried looks ok. Did you put it in the 'Value code' or 'Output code' field?
Whenever I've used Global PHP I can only access the $data variable if I put my code in the 'Output code' field
Answer!
After analyzing the output of $data, I realized I needed to drill down -- WAY down -- the array stack.