I am very new to Drupal programming and I am now trying to take my first steps there. I want to start off with the very basics such as iterate thought the items of a node and print them.
Based on this node object reference I have something like this in my code
$value = $node->title; dpm($value , $name = "Node's title");
but how would I iterate though the node's fields. Here's an example of some fields printed from devel
field_event (Array, 1 element)
0 (Array, 5 elements) value (String, 19 characters ) 2012-03-17 08:00:00 value2 (String, 19 characters ) 2012-03-18 15:00:00 timezone (String, 13 characters ) Europe/Athens timezone_db (String, 3 characters ) UTC date_type (String, 8 characters ) datetime
field_city (Array, 1 element)
0 (Array, 2 elements) tid (String, 1 characters ) 1 taxonomy_term (Object) stdClass tid (String, 1 characters ) 1 vid (String, 1 characters ) 2 name (String, 10 characters ) London description (String, 0 characters ) format (String, 13 characters ) filtered_html weight (String, 1 characters ) 0 vocabulary_machine_name (String, 4 characters ) city rdf_mapping (Array, 5 elements)
The first one is a date object and the second one is a taxonomy object. How would I access their data? Let's say I want the value2 for the date field and the name of the taxonomy term. Is this how you would go grab them?
$value = $node->field_event->value2; $value = $node->field_city->taxonomy_term->name;
I am pretty confused on how you iterate though this maze of objects and arrays. Any simple explanations with examples?