I have been trying for some time to figure out how to access information in the view using the php code. I was able to get regular info by using print var_dump($data, TRUE) to get all the available fields listed. I then navigate to each field dereferencing the array as I go with this statement print var_dump($data->field_field_equipmenttype[0]['raw'], TRUE). I am not sure if this is the correct or intended way or now. I also use a lot of reference content utilizing Node Reference. I have equipment with a node reference of type. To get to the title of the referenced node i had to use this code print var_dump($data->field_field_equipmenttype[0]['raw']['node']->title, TRUE);. When you are dereferencing the array if you run into object(stdClass) that is returning an object and you need to use '->' to get to the next value. If this is not he right way to get to this data then please let me know. I have a variable $row->field_equipmenttype that should return this data but does not. Hope this helps someone or someone will correct me.

Below is my actual array that I am navigating

object(stdClass)#253 (15) { ["nid"]=> string(3) "545" ["node_title"]=> string(1) "2" ["field_data_field_inspectionexpiration_field_inspectionexpira"]=> NULL ["field_data_field_licenseexpiration_field_licenseexpiration_v"]=> NULL ["field_data_field_inspectionexpiration_node_entity_type"]=> string(4) "node" ["field_data_field_equipmenttype_node_entity_type"]=> string(4) "node" ["field_data_field_licenseexpiration_node_entity_type"]=> string(4) "node" ["field_data_field_equipmentlocation_node_entity_type"]=> string(4) "node" ["views_php_0"]=> string(7) "Expired" ["_field_data"]=> array(1) { ["nid"]=> array(2) { ["entity_type"]=> string(4) "node" ["entity"]=> object(stdClass)#308 (59) { ["vid"]=> string(3) "548" ["uid"]=> string(3) "101" ["title"]=> string(1) "2" ["log"]=> string(0) "" ["status"]=> string(1) "1" ["comment"]=> string(1) "0" ["promote"]=> string(1) "0" ["sticky"]=> string(1) "0" ["ds_switch"]=> string(0) "" ["nid"]=> string(3) "545" ["type"]=> string(9) "equipment" ["language"]=> string(3) "und" ["created"]=> string(10) "1321999380" ["changed"]=> string(10) "1321999380" ["tnid"]=> string(1) "0" ["translate"]=> string(1) "0" ["revision_timestamp"]=> string(10) "1321999380" ["revision_uid"]=> string(3) "101" ["body"]=> array(1) { ["und"]=> array(1) { [0]=> array(5) { ["value"]=> string(10) "1993 IHC" ["summary"]=> string(0) "" ["format"]=> NULL ["safe_value"]=> string(10) "1993 IHC" ["safe_summary"]=> string(0) "" } } } ["field_chassisyear"]=> array(1) { ["und"]=> array(1) { [0]=> array(4) { ["value"]=> string(19) "1993-01-01T00:00:00" ["timezone"]=> string(16) "America/New_York" ["timezone_db"]=> string(16) "America/New_York" ["date_type"]=> string(4) "date" } } } ["field_equipmentphoto"]=> array(0) { } ["field_chassismanuf"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(13) "International" ["format"]=> NULL ["safe_value"]=> string(13) "International" } } } ["field_chassismodel"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(23) "International 4800 4x4" ["format"]=> NULL ["safe_value"]=> string(23) "International 4800 4x4" } } } ["field_gvw"]=> array(0) { } ["field_vin"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(17) "1HTSEPPN4PH502736" ["format"]=> NULL ["safe_value"]=> string(17) "1HTSEPPN4PH502736" } } } ["field_licenseplate"]=> array(0) { } ["field_licenseexpiration"]=> array(0) { } ["field_inspectionexpiration"]=> array(0) { } ["field_engine"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(15) "Diesel- DTA 466" ["format"]=> NULL ["safe_value"]=> string(15) "Diesel- DTA 466" } } } ["field_transmission"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(9) "Automatic" ["format"]=> NULL ["safe_value"]=> string(9) "Automatic" } } } ["field_axle"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(6) "Single" ["format"]=> NULL ["safe_value"]=> string(6) "Single" } } } ["field_brakes"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(3) "Air" ["format"]=> NULL ["safe_value"]=> string(3) "Air" } } } ["field_tires"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(9) "11 R 22.5" ["format"]=> NULL ["safe_value"]=> string(9) "11 R 22.5" } } } ["field_unityear"]=> array(1) { ["und"]=> array(1) { [0]=> array(4) { ["value"]=> string(19) "1993-01-01T00:00:00" ["timezone"]=> string(16) "America/New_York" ["timezone_db"]=> string(16) "America/New_York" ["date_type"]=> string(4) "date" } } } ["field_unitmanufacturer"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(9) "Hi-Ranger" ["format"]=> NULL ["safe_value"]=> string(9) "Hi-Ranger" } } } ["field_unitmodel"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(9) "4800 4X4" ["format"]=> NULL ["safe_value"]=> string(9) "4800 4X4" } } } ["field_unitserialnumber"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(9) "039318661" ["format"]=> NULL ["safe_value"]=> string(9) "039318661" } } } ["field_boomheight"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(2) "48" ["format"]=> NULL ["safe_value"]=> string(2) "48" } } } ["field_basket"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(6) "Double" ["format"]=> NULL ["safe_value"]=> string(6) "Double" } } } ["field_cabprotector"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(2) "No" ["format"]=> NULL ["safe_value"]=> string(2) "No" } } } ["field_utilitybody"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(3) "Yes" ["format"]=> NULL ["safe_value"]=> string(3) "Yes" } } } ["field_outriggers"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(1) "2" ["format"]=> NULL ["safe_value"]=> string(1) "2" } } } ["field_winch"]=> array(0) { } ["field_unitotherinfo"]=> array(1) { ["und"]=> array(1) { [0]=> array(3) { ["value"]=> string(74) "4X4 W/ Front Capstan Winch 2- Yellow Light Front Cab 2-Spot Lights Front" ["format"]=> NULL ["safe_value"]=> string(74) "4X4 W/ Front Capstan Winch 2- Yellow Light Front Cab 2-Spot Lights Front" } } } ["field_equipmenttype"]=> array(1) { ["und"]=> array(1) { [0]=> array(1) { ["nid"]=> string(3) "275" } } } ["field_equipmentlocation"]=> array(0) { } ["rdf_mapping"]=> array(9) { ["rdftype"]=> array(2) { [0]=> string(9) "sioc:Item" [1]=> string(13) "foaf:Document" } ["title"]=> array(1) { ["predicates"]=> array(1) { [0]=> string(8) "dc:title" } } ["created"]=> array(3) { ["predicates"]=> array(2) { [0]=> string(7) "dc:date" [1]=> string(10) "dc:created" } ["datatype"]=> string(12) "xsd:dateTime" ["callback"]=> string(12) "date_iso8601" } ["changed"]=> array(3) { ["predicates"]=> array(1) { [0]=> string(11) "dc:modified" } ["datatype"]=> string(12) "xsd:dateTime" ["callback"]=> string(12) "date_iso8601" } ["body"]=> array(1) { ["predicates"]=> array(1) { [0]=> string(15) "content:encoded" } } ["uid"]=> array(2) { ["predicates"]=> array(1) { [0]=> string(16) "sioc:has_creator" } ["type"]=> string(3) "rel" } ["name"]=> array(1) { ["predicates"]=> array(1) { [0]=> string(9) "foaf:name" } } ["comment_count"]=> array(2) { ["predicates"]=> array(1) { [0]=> string(16) "sioc:num_replies" } ["datatype"]=> string(11) "xsd:integer" } ["last_activity"]=> array(3) { ["predicates"]=> array(1) { [0]=> string(23) "sioc:last_activity_date" } ["datatype"]=> string(12) "xsd:dateTime" ["callback"]=> string(12) "date_iso8601" } } ["print_display"]=> int(1) ["print_display_comment"]=> int(0) ["print_display_urllist"]=> int(1) ["name"]=> string(9) "datherton" ["picture"]=> string(1) "0" ["data"]=> NULL ["print_mail_display"]=> int(1) ["print_mail_display_comment"]=> int(0) ["print_mail_display_urllist"]=> int(1) ["print_pdf_display"]=> int(1) ["print_pdf_display_comment"]=> int(0) ["print_pdf_display_urllist"]=> int(1) } } } ["field_field_inspectionexpiration_1"]=> array(0) { } ["field_field_equipmenttype"]=> array(1) { [0]=> array(2) { ["rendered"]=> array(1) { ["#markup"]=> string(12) "Bucket Truck" } ["raw"]=> array(3) { ["nid"]=> string(3) "275" ["access"]=> bool(true) ["node"]=> object(stdClass)#321 (14) { ["nid"]=> string(3) "275" ["vid"]=> string(3) "278" ["type"]=> string(14) "equipment_type" ["language"]=> string(3) "und" ["title"]=> string(12) "Bucket Truck" ["uid"]=> string(1) "1" ["status"]=> string(1) "1" ["created"]=> string(10) "1302051715" ["changed"]=> string(10) "1302051715" ["comment"]=> string(1) "0" ["promote"]=> string(1) "0" ["sticky"]=> string(1) "0" ["tnid"]=> string(1) "0" ["translate"]=> string(1) "0" } } } } ["field_field_inspectionexpiration"]=> array(0) { } ["field_field_licenseexpiration"]=> array(0) { } ["field_field_equipmentlocation"]=> array(0) { } } bool(true) 

Comments

johnv’s picture

Status: Needs review » Closed (duplicate)

1. besides using vr_dump, you can use e.g., dpm($data);
2. I was expecting a patch, due to the status 'needs review', but alas..
3. since the status should be changed anyway, I'll set it as a duplicate of e.g. this: http://drupal.org/node/1140896#comment-5340594