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:
$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:
$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!
Comment | File | Size | Author |
---|---|---|---|
#15 | contemplate-1040748.patch | 853 bytes | dgtlmoon |
#10 | contemplate-missing-teaser.patch | 577 bytes | rhouse |
Comments
Comment #1
yngens CreditAttribution: yngens commentedThis 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.
Comment #2
Swebmas CreditAttribution: Swebmas commentedIt's not working for me.
Comment #3
Swebmas CreditAttribution: Swebmas commentedSorry, the problem I have is about the image field that I can't print.
Comment #4
marcusx CreditAttribution: marcusx commentedSame problem here. Images are not displayed any more if I activate contemplate. Any solution for this so far?
Comment #5
jrglasgow CreditAttribution: jrglasgow commentedthis has been committed, please test the dev version
Comment #7
ergophobe CreditAttribution: ergophobe commentedI'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.
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).
Comment #8
ali_b CreditAttribution: ali_b commented+1
Comment #9
rhouse CreditAttribution: rhouse commentedIt turns out that the $node->body array can have no elements. so the lines 813 and 814 mentioned in @7 must be changed to:
This is relative to 7.x-1.0-alpha2.
Comment #10
rhouse CreditAttribution: rhouse commentedHere's that fix as a patch.
Comment #11
OnkelTem CreditAttribution: OnkelTem commentedThe 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?Comment #12
marvix CreditAttribution: marvix commented+1
Comment #13
OnkelTem CreditAttribution: OnkelTem commentedChanging title, since its not fixed.
Comment #14
dgtlmoon CreditAttribution: dgtlmoon commentedSome 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).
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
Comment #15
dgtlmoon CreditAttribution: dgtlmoon commentedAnd 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!
Comment #16
dgtlmoon CreditAttribution: dgtlmoon commentedtested and comitted
Comment #17
marioboro CreditAttribution: marioboro commentedHello,
did anyone found a solution? I have the same troubles.
Thank´s
Comment #18
dgtlmoon CreditAttribution: dgtlmoon commentedcan you paste into the comment the exact error you are seeing?
Comment #19
ali_b CreditAttribution: ali_b commentedNotice: Undefined index: sk v eval() (line 4 .../sites/all/modules/contemplate/contemplate.module(833) : eval()'d code).
Comment #20
tatianab CreditAttribution: tatianab commentedHi,
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).
Comment #22
pvasili CreditAttribution: pvasili commentedI have the same error (#20)
Comment #23
pvasili CreditAttribution: pvasili commentedThis bug is you present "Multilingual support" for this type of material. And if you set any language (eg Ru) for node.
Comment #24
Greg Adams CreditAttribution: Greg Adams commentedGetting this error, no matter how I set things up.
Any ideas??
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commentedHi !
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 :
with this one :
NOTE : I think it should be better to use $language_to_display in the templates rather than $node->language.
Comment #26
royalmedia CreditAttribution: royalmedia commentedIm 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).
Comment #27
amogiz CreditAttribution: amogiz commentedNothing works for me …
Comment #28
amogiz CreditAttribution: amogiz commentedNo possibility ti have a solution ?
Each time a contemplate page is loaded i got hoses many warnings … Difficult to use the module with this.
Comment #29
OnkelTem CreditAttribution: OnkelTem commented@amogiz
Consider using Display Suite instead.
Comment #30
amogiz CreditAttribution: amogiz commentedSorry, 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
Comment #31
joancatala CreditAttribution: joancatala commented@amogiz I'm having the same error :-(
Comment #32
OnkelTem CreditAttribution: OnkelTem commented@joancatala
Same recommendation: Display Suite
Comment #33
chaiwei CreditAttribution: chaiwei commentedI 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:
Change to:
Comment #34
dgtlmoon CreditAttribution: dgtlmoon commentedcan you convert that to a .patch?
Comment #35
ajlow CreditAttribution: ajlow commentedBump - 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
Comment #36
abdulbasitnawab CreditAttribution: abdulbasitnawab commentedHi
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
$node->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.