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:

= $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:

= $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!



yngens’s picture

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:

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:

print $node->field_link[$node->language][0]['title']
print $node->field_industry[$node->language][0]['taxonomy_term']->name
print $node->field_client[$node->language][0]['taxonomy_term']->name
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.

Swebmas’s picture

It's not working for me.

Swebmas’s picture

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

marcusx’s picture

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

jrglasgow’s picture

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.

ergophobe’s picture

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).

ali_b’s picture


rhouse’s picture

Title:Notice: Undefined index: und at contemplate_eval() node language issue» FIXED: 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.

rhouse’s picture

new577 bytes

Here's that fix as a patch.

OnkelTem’s picture

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?

marvix’s picture


OnkelTem’s picture

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

Changing title, since its not fixed.

dgtlmoon’s picture

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

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

dgtlmoon’s picture

Status:Active» Needs review
Issue tags:+D7 stable release blocker
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!

dgtlmoon’s picture

Status:Needs review» Fixed

tested and comitted

marioboro’s picture


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


dgtlmoon’s picture

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

ali_b’s picture

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

tatianab’s picture

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.

pvasili’s picture

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

I have the same error (#20)

pvasili’s picture

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

Greg Adams’s picture

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).
zigazou’s picture

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 :

= (
$node->body[$display_language]) ?
$display_language :
$node->body[$default_language]) ?
$default_language :

with this one :

// 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;

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

royalmedia’s picture

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).

amogiz’s picture

Nothing works for me …

amogiz’s picture

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.

OnkelTem’s picture


Consider using Display Suite instead.

amogiz’s picture

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 ?

joancatala’s picture

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

OnkelTem’s picture


Same recommendation: Display Suite

chaiwei’s picture

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.


//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:

//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'] : '';
dgtlmoon’s picture

can you convert that to a .patch?

ajlow’s picture

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

abdulbasitnawab’s picture

Issue summary:View changes

I solved this issue by going to my content type and clicking on content -> manage display->content type (this only appear when the module is installed). In the editor write this as first line

->language = 'und';

as in any language it returns the language code as und but it fetches the contents in the selected language, After this issue it started fetching the correct values.
I guess this will work properly for single language installation.