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: {"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.
Just did a print_r on $view->result[1].
stdClass Object ( [node_title] => "The Trial" by Franz Kafka [nid] => 52 [node_created] => 1334720754 [field_data_field_subject_node_entity_type] => node [_field_data] => Array ( [nid] => Array ( [entity_type] => node [entity] => stdClass Object ( [vid] => 52 [uid] => 1 [title] => "The Trial" by Franz Kafka [log] => [status] => 1 [comment] => 2 [promote] => 1 [sticky] => 0 [nid] => 52 [type] => assignment [language] => und [created] => 1334720754 [changed] => 1334733704 [tnid] => 0 [translate] => 0 [revision_timestamp] => 1334733704 [revision_uid] => 1 [body] => Array ( [und] => Array ( [0] => Array ( [value] => Many attempts have been made to examine Kafka's legal background and the role of law in his fiction. These attempts remain relatively few in number compared to the vast collection of literature devoted to the study of his life and works, and marginal to legal scholarship. Mainstream studies of Kafka's works normally present his fiction as an engagement with absurdity, a critique of bureaucracy or a search for redemption, failing to account for the images of law and legality which constitute an important part of "the horizon of meaning" in his fiction. However, James Hawes argues many of Kafka's descriptions of the legal proceedings in The Trial – metaphysical, absurd, bewildering and "Kafkaesque" as they might appear – are, in fact, based on accurate and informed (although exaggerated) descriptions of German and Austrian criminal proceedings of the time, not well understood by many British or American people, who were familiar with an adversarial rather than inquisitorial system of justice. Similarly, the requirement for the traveller to register with the authorities in The Castle to stay a night seems repressive and odd to Britons and Americans, whereas in the present-day Germans (and most continental Europeans) are required to register their address (and hoteliers their guests) with the local authorities. The significance of law in Kafka's fiction is also neglected within legal scholarship, for as Richard Posner pointed out, most lawyers do not consider writings about law in the form of fiction of any relevance to the understanding or the practice of law. Regardless of the concerns of mainstream studies of Kafka with redemption and absurdity, and what jurists such as Judge Posner might think relevant to law and legal practice, the fact remains that Kafka was an insurance lawyer who, besides being involved in litigation, was also "keenly aware of the legal debates of his day" (Ziolkowski, 2003, p. 224). In a recent study which uses Kafka's office writings as its point of departure, Reza Banakar argues that "legal images in Kafka's fiction are worthy of examination, not only because of their bewildering, enigmatic, bizarre, profane and alienating effects, or because of the deeper theological or existential meaning they suggest, but also as a particular concept of law and legality which operates paradoxically as an integral part of the human condition under modernity. To explore this point Kafka's conception of law is placed in the context of his overall writing as a search for Heimat which takes us beyond the instrumental understanding of law advocated by various schools of legal positivism and allows us to grasp law as a form of experience" [summary] => [format] => filtered_html [safe_value] =>Many attempts have been made to examine Kafka's legal background and the role of law in his fiction. These attempts remain relatively few in number compared to the vast collection of literature devoted to the study of his life and works, and marginal to legal scholarship. Mainstream studies of Kafka's works normally present his fiction as an engagement with absurdity, a critique of bureaucracy or a search for redemption, failing to account for the images of law and legality which constitute an important part of "the horizon of meaning" in his fiction.
However, James Hawes argues many of Kafka's descriptions of the legal proceedings in The Trial – metaphysical, absurd, bewildering and "Kafkaesque" as they might appear – are, in fact, based on accurate and informed (although exaggerated) descriptions of German and Austrian criminal proceedings of the time, not well understood by many British or American people, who were familiar with an adversarial rather than inquisitorial system of justice. Similarly, the requirement for the traveller to register with the authorities in The Castle to stay a night seems repressive and odd to Britons and Americans, whereas in the present-day Germans (and most continental Europeans) are required to register their address (and hoteliers their guests) with the local authorities.
The significance of law in Kafka's fiction is also neglected within legal scholarship, for as Richard Posner pointed out, most lawyers do not consider writings about law in the form of fiction of any relevance to the understanding or the practice of law. Regardless of the concerns of mainstream studies of Kafka with redemption and absurdity, and what jurists such as Judge Posner might think relevant to law and legal practice, the fact remains that Kafka was an insurance lawyer who, besides being involved in litigation, was also "keenly aware of the legal debates of his day" (Ziolkowski, 2003, p. 224).
In a recent study which uses Kafka's office writings as its point of departure, Reza Banakar argues that "legal images in Kafka's fiction are worthy of examination, not only because of their bewildering, enigmatic, bizarre, profane and alienating effects, or because of the deeper theological or existential meaning they suggest, but also as a particular concept of law and legality which operates paradoxically as an integral part of the human condition under modernity. To explore this point Kafka's conception of law is placed in the context of his overall writing as a search for Heimat which takes us beyond the instrumental understanding of law advocated by various schools of legal positivism and allows us to grasp law as a form of experience"
[safe_summary] => ) ) ) [field_files] => Array ( [und] => Array ( [0] => Array ( [fid] => 16 [display] => 1 [description] => [uid] => 1 [filename] => Franz Kafka - The Trial.pdf [uri] => public://Franz Kafka - The Trial.pdf [filemime] => application/pdf [filesize] => 977591 [status] => 1 [timestamp] => 1334720754 [rdf_mapping] => Array ( ) ) ) ) [field_submissions] => Array ( ) [field_class] => Array ( [und] => Array ( [0] => Array ( [value] => 9B ) ) ) [field_subject] => Array ( [und] => Array ( [0] => Array ( [value] => English ) ) ) [rdf_mapping] => Array ( [rdftype] => Array ( [0] => sioc:Item [1] => foaf:Document ) [title] => Array ( [predicates] => Array ( [0] => dc:title ) ) [created] => Array ( [predicates] => Array ( [0] => dc:date [1] => dc:created ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [changed] => Array ( [predicates] => Array ( [0] => dc:modified ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [body] => Array ( [predicates] => Array ( [0] => content:encoded ) ) [uid] => Array ( [predicates] => Array ( [0] => sioc:has_creator ) [type] => rel ) [name] => Array ( [predicates] => Array ( [0] => foaf:name ) ) [comment_count] => Array ( [predicates] => Array ( [0] => sioc:num_replies ) [datatype] => xsd:integer ) [last_activity] => Array ( [predicates] => Array ( [0] => sioc:last_activity_date ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) ) [cid] => 0 [last_comment_timestamp] => 1334720754 [last_comment_name] => [last_comment_uid] => 1 [comment_count] => 0 [name] => admin [picture] => 0 [data] => a:1:{s:7:"overlay";i:1;} ) ) ) [field_field_subject] => Array ( [0] => Array ( [rendered] => Array ( [#markup] => English [#access] => 1 ) [raw] => Array ( [value] => English ) ) ) )
In the view I have selected:
Content: Title
Content: Subject (Subject)
Content: Nid (Nid)
Solution:
$view_fields = $view->style_plugin->options['columns']; foreach ($view->result as $index => $row) { $view->row_index = $index; foreach($view_fields as $field){ $field_output = $view->style_plugin->get_field_value($index, $field); error_log($field.": ".$field_output."\n", 3, "debug.log"); } }
Instead of the error_log build an array instead or whatever you need