I'm getting this error: Notice: Undefined index: und in include() (line 24 of /home/cliffdwellerproductions/dev.cliffdwellerdigital.com/Dahl/sites/all/themes/basic/templates/node--page2.tpl.php).
the code is:
if ($node->field_body_left !== NULL) :
$text = trim($node->field_body_left['und']['0']['value']);
else:
$text = '';
Please help, as I haven't been able to define the variable...
Alf
Your $node->field_body_left variable is existent but it doesn't have an 'und' element.
It looks like you're attempting to check for an empty field, but you're using $field_body_left!==null
which will only be false if the variable is literally null
. When a drupal field is present but empty, it's usually equal to array()
. Use !=
instead of !==
, and then it will correctly detect both null variables and empty arrays and move on.
--
Extra info: If the variable had a value, its structure would be:
$field_body_left = array(
'und' => array(
0 => array (
'value' => YOURVALUE
)
)
)
But since it doesn't have a value, its structure is:
$field_body_left = array()