Closed (fixed)
Project:
Views (for Drupal 7)
Version:
7.x-3.3
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
19 Apr 2012 at 02:34 UTC
Updated:
7 May 2012 at 10:20 UTC
I am building a module where I would like to use the fields from a user generated view. So let's say the user create a view with 3 fields: Class, Subject, & Nid. I run views_get_view_result() on the view, but that returns entire node objects. How do I get the simple values like this ex: {"1 grade", "English", 54} as an array perhaps?
Remember I don't know beforehand what fields have been selected by the user, so I have to get the raw data like that, or be able to see what fields have been selected and in what order.
Thanks !
Comments
Comment #1
dawehnerWell views_get_view_result returns the raw database result, and yes there are entities involved there. That's "simply"
how d7 has to work.
You might want to try $view->style_plugin->get_field($row_index, 'field') to get the rendered field.
Comment #2
SlashCrew commentedShould anyone need it for future reference:
Instead of the error_log build an array or whatever you need. This code only work with single values, if you need to handle arrays then handle it in the second foreach loop. Thanks for the help Daniel!