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.
Krumo Output of View Object

CommentFileSizeAuthor
nest.jpg68.82 KBdefconjuan

Comments

daggerhart’s picture

Try:

$view->result[0]->field_field_bgts_obgligationcum[0]['raw']['value'];

merlinofchaos’s picture

Status: Active » Fixed

You 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.

defconjuan’s picture

Thanks daggerhart. That was it. Really appreciate it.

defconjuan’s picture

Thanks 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!

merlinofchaos’s picture

Ok. 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.