How can i fix the error message?

the error message is Notice: Undefined index: und in include() (line 9 of /var/www/html/sites/all/modules/custom/theme/icons.tpl.php).

my code is:

global $language ;  
global $base_url , $base_path ;
$lang = $language->language;
$count = 0;
foreach ($data as $kay => $node_obj) {
    $node = node_load($node_obj->nid);
if (isset($node->field_description[$lang])) {
    $img_url = $node->field_icon['und'][0]['uri'] ;


  • 1
    Depending on installed modules, and templates, the array keys can vary. Have you tried something like: ->field_icon[‘#items’][‘uri’][‘value’]? Jun 16, 2019 at 0:22

1 Answer 1


I fix it by


!empty( )

like this

$img_url = !empty($node->field_icon['und'][0]['uri']) ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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