1

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:

<?php 
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'] ;
$count++;

?>

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

1 Answer 1

1

I fix it by

add

!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 and acknowledge you have read our privacy policy.

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