Closed (fixed)
Project:
Views (for Drupal 7)
Version:
7.x-3.0-rc3
Component:
page displays
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
7 Dec 2011 at 15:47 UTC
Updated:
21 Dec 2011 at 17:10 UTC
I'm trying to access a value nested deep within the view object. I can return top level items that aren't in a nested array for example :
<?=$view->db_table;?> returns views_view.
But I can't get the syntax right to access the value nested deep within this object. I'm trying to get the value for the deepest highlighted element below, can someone help me with the syntax? I've spent a crap-load of time trying different variations with no success.

| Comment | File | Size | Author |
|---|---|---|---|
| nest.jpg | 68.82 KB | defconjuan |
Comments
Comment #1
daggerhart commentedTry:
$view->result[0]->field_field_bgts_obgligationcum[0]['raw']['value'];
Comment #2
merlinofchaos commentedYou should try to avoid maniulating $view->result directly.
You may want $view->field[$field_id]->get_value($view->result[$row_index])
However, Views doesn't interpret field api data structures for you; it will still return you an array. You'll have to interpret that data yourself, I'm afraid.
Comment #3
defconjuan commentedThanks daggerhart. That was it. Really appreciate it.
Comment #4
defconjuan commentedThanks merlinofchaos. I actually tried doing that originally, but there's a bug in the Chart module (http://drupal.org/node/1256050) when it comes to using Charting with Views. It's on their end. But the short of it is that the nid is returned as the value instead of actual field value so I need to get the field value directly. Anyhow, it's fixed and I appreciate your guys help!
Comment #5
merlinofchaos commentedOk. You might want to at least look at $view->field[$field_id]->field_alias which will tell you the correct key to use within $view->result -- because the alias is not guaranteed to remain stable if the view ever changes. That alias uses collision detection and if something else with a similar alias gets added before it, it could change. Using the field_alias will guarantee you always retrieve the correct value.