Notice: Undefined index: und at contemplate_eval() (line 796 in /home/content/a/l/e/alex8452/html/openinghours/sites/default/modules/contemplate/contemplate.module).
Notice: Undefined index: und at contemplate_eval() (line 797 in /home/content/a/l/e/alex8452/html/openinghours/sites/default/modules/contemplate/contemplate.module).

When I've added a second language as default language, a new created node with content template keeps showing these error messages. I've probably found the problem:
in the contemplate.module, line 796 and 797 file:

<?php
  $teaser
= $node->body['und'][0]['safe_summary'];
 
$body = $node->body['und'][0]['safe_value'];
?>

The language attribute was hard coded to "udn". But it's actually related to your configuration. So I changed it to:
<?php
  $teaser
= $node->body[$node->language][0]['safe_summary'];
 
$body = $node->body[$node->language][0]['safe_value'];
?>

It's good now. But I'm not sure if any side effects will be caused. Anyone knows that? Thanks!
Files: 

Comments

This makes error go, however makes template available for only one language. For example, to output body I need to place the following into Body Template field:

<?php
print check_plain($node->body['en'][0]['value'])
?>

But since, the language code is specified in the template, it does not work for other languages. Including language check in the template feels wrong path, it should be detected automatically, shouldn't it?

Update: I had to manually change all the occurrences of ['en'] to [$node->language] and everything works fine now:

<?php
print $node->field_link[$node->language][0]['title']
?>
<?php
print $node->field_industry[$node->language][0]['taxonomy_term']->name
?>
<?php
print $node->field_client[$node->language][0]['taxonomy_term']->name
?>

<?php
print check_plain($node->body[$node->language][0]['value'])
?>

However, this should be fixed in a way so that the available variables for inclusion into template would contain [$node->language]s, not ['en']s.

It's not working for me.

Sorry, the problem I have is about the image field that I can't print.

Same problem here. Images are not displayed any more if I activate contemplate. Any solution for this so far?

Version:7.x-1.0-alpha1» 7.x-1.x-dev
Status:Needs review» Fixed

this has been committed, please test the dev version

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status:Closed (fixed)» Active

I'm still getting this with a fresh install of D7 as of yesterday, all modules up to date and running the April 3 dev release of contemplate, all caches flushed.

* Notice: Undefined index: und in contemplate_eval() (line 813 of /home/yofore/public_html/sites/all/modules/contemplate/contemplate.module).
    * Notice: Undefined index: und in contemplate_eval() (line 814 of /home/yofore/public_html/sites/all/modules/contemplate/contemplate.module).

In the template itself, I can output this, test for $node->field_name['und'], etc and there's no problem.

Separate issue, but I'm also getting an undefined index notice, but only on the template overview page (admin/structure/types/templates)

Notice: Undefined index: body-file in contemplate_admin() (line 198 of /home/yofore/public_html/sites/all/modules/contemplate/contemplate.module).

+1

Title:Notice: Undefined index: und at contemplate_eval() node language issueFIXED: Undefined index: und at contemplate_eval() node language issue

It turns out that the $node->body array can have no elements. so the lines 813 and 814 mentioned in @7 must be changed to:

  if (count($node->body) != 0) {
    $teaser = $node->body[$language_to_display][0]['safe_summary'];
    $body = $node->body[$language_to_display][0]['safe_value'];
  } else {
    $teaser = '';
    $body = '';
  }

This is relative to 7.x-1.0-alpha2.

StatusFileSize
new577 bytes

Here's that fix as a patch.

The problem didn't go. Or rather - it appears for any not language neutral nodes.

I wonder is this Drupal's bug or Contemplate's one. To reproduce:

1) Install D7.7 + Contemplate.
2) Enable Locale module.
3) Add [any] language and make it default.
4) Create a node and it will be set to [that] language.
5) Now use contemplate for that node type and get neither teaser nor body - they are underfined...

The reason - contemplate_eval() function first tries to know a node's language and then takes `body` value using that language as index, while the `body` still lives under ['und'] index --- anybody knows WHY?

+1

Title:FIXED: Undefined index: und at contemplate_eval() node language issueUndefined index: und at contemplate_eval() node language issue

Changing title, since its not fixed.

Some investigation shows that this is coming from a node_load, where it tries to prepare a node to give you an example set of fields

See node_build_content and node_load in contemplate_node_views($type).

stdClass Object
(
    [vid] => 2
    [uid] => 1
    [title] => test
...
    [body] => Array
        (
            [und] => Array
                (
....

Your 'und' can be traced all the way back to your raw node table..

'und' means language undefined

http://api.drupal.org/api/drupal/includes--bootstrap.inc/constant/LANGUA...

If I replace any 'und' with $node->language it seems to work

Status:Active» Needs review
Issue tags:+D7 stable release blocker
StatusFileSize
new853 bytes

And heres my patch, it basically just tweaks the example template.

Might need testing where your first node is a defined language, but this should cover 99%

Please test!

Status:Needs review» Fixed

tested and comitted

Hello,

did anyone found a solution? I have the same troubles.

Thank´s

can you paste into the comment the exact error you are seeing?

Notice: Undefined index: sk v eval() (line 4 .../sites/all/modules/contemplate/contemplate.module(833) : eval()'d code).

Hi,
I have some errors even after installing the last version of module (contemplate-7.x-1.x-dev / 2011-Sep-21):

Notice: Undefined index: ru в функции contemplate_eval() (строка 829 в файле .../sites/all/modules/contemplate/contemplate.module).
Notice: Undefined index: ru в функции contemplate_eval() (строка 830 в файле .../sites/all/modules/contemplate/contemplate.module).
Notice: Undefined index: ru в функции eval() (строка 1 в файле .../sites/all/modules/contemplate/contemplate.module(833) : eval()'d code).

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Priority:Normal» Major
Status:Closed (fixed)» Needs review

I have the same error (#20)

This bug is you present "Multilingual support" for this type of material. And if you set any language (eg Ru) for node.

Getting this error, no matter how I set things up.
Any ideas??

Notice: Undefined index: safe_value in eval() (line 22 of /.../sites/all/modules/contemplate/contemplate.module(833) : eval()'d code).

Hi !

I just installed contemplate for Drupal 7 and it appears that though $node->language is set to a language ('fr' in my case), $node->body[$node->language] is not populated, but $node->body['und'] is !

This leads to the following change in contemplate.module

On line 818, I replace this code :

<?php
  $language_to_display
= (
    isset(
$node->body[$display_language]) ?
   
$display_language :
    (
      isset(
$node->body[$default_language]) ?
     
$default_language :
     
$node_language
   
)
  );
?>

with this one :

<?php
 
// choose the language
 
$language_to_display = 'und';
 
$languages = array($display_language, $default_language, $node_language);
  foreach (
$languages as $language) {
    if (isset(
$node->body[$language])) {
     
$language_to_display = $language;
      break;
    }
  }
?>

NOTE : I think it should be better to use $language_to_display in the templates rather than $node->language.

Im getting these errors too can anyone help???

Notice: Undefined offset: 0 in eval() (line 4 of /Users/Kenz/Desktop/MyPartyCityMPC/sites/all/modules/contemplate/contemplate.module(833) : eval()'d code).
Notice: Undefined offset: 0 in eval() (line 4 of /Users/Kenz/Desktop/MyPartyCityMPC/sites/all/modules/contemplate/contemplate.module(833) : eval()'d code).
Notice: Undefined index: und in eval() (line 11 of /Users/Kenz/Desktop/MyPartyCityMPC/sites/all/modules/contemplate/contemplate.module(833) : eval()'d code).

Nothing works for me …

No possibility ti have a solution ?
Each time a contemplate page is loaded i got hoses many warnings … Difficult to use the module with this.

@amogiz

Consider using Display Suite instead.

Sorry, but i use and need Contemplate :)
The problem is that all D7 versions makes error, what ever i do.
I made a the templates I need and it works but I can't use and propose to my client a website with 15 lines of Notices.

Would be great to solve this problem.

My website is in French.
Could it be a relation with all these errors ?
Thanx

@amogiz I'm having the same error :-(

@joancatala

Same recommendation: Display Suite

I added some validation to contemplate.module, line 829 & line 830
Just notice this error occurs because I don't have any value in node body.

Original:

<?php
 
//CCK supports nodes without body.
 
$teaser = (isset($node->body)) ? $node->body[$language_to_display][0]['safe_summary'] : '';
 
$body = (isset($node->body)) ? $node->body[$language_to_display][0]['safe_summary'] : '';
?>

Change to:

<?php
//CCK supports nodes without body.
 
$teaser = (isset($node->body) && isset($node->body[$language_to_display])) ? $node->body[$language_to_display][0]['safe_summary'] : '';
 
$body = (isset($node->body) && isset($node->body[$language_to_display])) ? $node->body[$language_to_display][0]['safe_summary'] : '';
?>

can you convert that to a .patch?

Bump - I get a similar error where I use a view for my content type and have no body or summary:

Notice: Undefined index: und in contemplate_eval() (line 871 of /Applications/MAMP/htdocs/mysite/sites/all/modules/contemplate/contemplate.module).

Notice: Undefined index: und in contemplate_eval() (line 872 of /Applications/MAMP/htdocs/mysite/sites/all/modules/contemplate/contemplate.module).

I'm using version 7.x-1.0-rc3+9-dev