I am using a custom image field in one of my content types, which I am accessing using the following code.

if ($content['field_heading']) { 
  print render($content['field_heading']);

Everything is fine, except that in administrative area I am seeing this error message:

Notice: Undefined index: field_heading in include() (line 4 of tridz7\sites\all\themes\tridz\node.tpl.php).

What could be the reason? Is there any workaround?

2 Answers 2


Probably you have nodes where the "field_heading" field has not been set, or you didn't enable the field in output tab on content type section.

Try this code:

if (!empty($content['field_heading'])) { 
  print render($content['field_heading']);

Drupal errors "Notice: Undefined index: profile in...".

Basically the particular above notice is created when PHP tries to access the index of an array, where the variable is not holding an array. Check that 'field_heading' has a value assigned to it in the $content array.

If this is your development server, you'll also want to disable displaying warnings. The link above also details how you can do this at the PHP/server level; you can also disable the error reporting to the screen on a production site in Drupal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.