Sorry for the code in the title, I couldn't think of a clearer way to ask it.
I have several nodes of the
location content type, and a view outputting teasers of those nodes. I want to do some custom stuff in
node--location.tpl.php to affect the teasers everywhere they're displayed. When I do a simple
dpm($node) to get at the variables, some field values are not always in the same place.
For instance, I have
field_phone that just has identically formatted phone numbers. For the first node in this view, that field is structured as
$node->field_phone['und']['safe_value']. But for the second node, it's simply
I know that
und has to do with translations, and perhaps means "undefined". I'm not doing anything with translations or localization or languages on the site, so it's not like this node is any different from other nodes that way.
What causes this, and is there a function or something that can help me test for and get at the value easily, or do I have to roll my own?
EDIT: Chris Rockwell below points out
field_get_items(). This seemed to solve my problem on the site I was working on the other day. But now, on a different site, it's failing for exactly the reason I bring up here.
I have a view that outputs three nodes. For some reason, when I
dpm($node) in the
node--node-type.tpl.php file, I get six variable dumps. The first one has
$node->field_link_image['und'], while all five others — INCLUDING the duplicate of this same node — just has
$node->field_link_image. And now,
field_get_items() is silently failing and returning false on those last five nodes.
So I go back to my original question: What causes this difference between some node variables and others, and what can I do about it?