With Drupal API I found you can get the values of a node with noad_load like so:
$thisnode = node_load($nid = $child2, $vid = NULL, $reset = FALSE);
Now it is easy to echo the title in this way
$thisnode->title;
But the array begins to get quite complex when I try and get data from the custom image_thumbnail field because it is array within array. See the full printed array for one node:
stdClass Object ( [vid] => 4 [uid] => 1 [title] => Who we are [log] => [status] => 1 [comment] => 0 [promote] => 0 [sticky] => 0 [nid] => 4 [type] => level_2 [language] => und [created] => 1345561152 [changed] => 1346982536 [tnid] => 0 [translate] => 0 [revision_timestamp] => 1346982536 [revision_uid] => 1 [body] => Array ( [und] => Array ( [0] => Array ( [value] => blah blah blah [summary] => [format] => plain_text [safe_value] =>
blah blah blah
[safe_summary] => ) ) ) [field_parent2] => Array ( [und] => Array ( [0] => Array ( [target_id] => 2 ) ) ) [field_level2_thumbnail_image] => Array ( [und] => Array ( [0] => Array ( [fid] => 4 [alt] => this is a photo [title] => this is a photo [width] => 308 [height] => 198 [uid] => 1 [filename] => article-image.png [uri] => public://article-image.png [filemime] => image/png [filesize] => 105660 [status] => 1 [timestamp] => 1346982536 [rdf_mapping] => Array ( ) ) ) ) [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 ) ) [name] => slawrence10 [picture] => 0 [data] => b:0; )
What's the best way to extract for example alt from *field_level2_thumbnail_image*?
I can do it like so:
$thisnode->field_level2_thumbnail_image['und'][0]['alt'];
But is this stable? Will 'und' always be 0? Am I missing something here?