warning: Invalid argument supplied for foreach()
danon1981 - March 5, 2009 - 03:12
| Project: | Internationalization |
| Version: | 5.x-2.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | danon1981 |
| Status: | closed |
Jump to:
Description
warning: Invalid argument supplied for foreach() in /home/vhosts/merelvanderknoop.com/httpdocs/modules/i18n/translation/translation.module on line 858.
On translated pages this error occurs, i have had a look at the mentioned file but I'm not a coder so i have no clue what the problem might be, who can be of assistance?
Thanks in advance!!

#1
#2
This is the piece of code from the mentioned file by the way.
/*** Get translations
*
* @param $params
* array of parameters
* @param $getall
* TRUE to get the also node itself
*/
function translation_node_get_translations($params, $getall = TRUE) {
foreach($params as $field => $value) {
$conds[] = "b.$field = '%s'";
$values[] = $value;
}
I think I solved the error by putting:
<?php$params = array();
?>
In front of the first mentioned $params in the file
But now I'm getting the same error for line 895
This is the code from around line 895:
/*** Returns node type for nid
*/
function translation_get_node_type($nid) {
return db_result(db_query('SELECT type FROM {node} WHERE nid=%d', $nid));
}
Help needed !!
#3
When I use the default Garland theme it seems it doesn't produce an error.
anyone???
#4
Ok found out that the problem must have to do with the different way of displaying the translation links in my self made template
This is de code from page.tpl.php
<?php foreach(civicspace_language_links($node->nid,$language) as $lang => $link): ?><li <?php print ($lang == $language) ? 'self' : $lang; ?>"> <span><?php print $link; ?></span></li>
<?php endforeach; ?>
This is the code form my template.php
/* Language display */function civicspace_language_links($nid,$language) {
$q = $_GET['q'];
$links = array();
if (function_exists('i18n_supported_languages')) {
$languages = i18n_supported_languages();
if (preg_match('#^node/\d+$#',$q)) {
$translations = translation_node_get_translations($nid);
foreach ($languages as $lang => $longname) {
if ($trnode = $translations[$lang]) {
$links[$lang]= l($longname, $lang.'/node/'.$trnode->nid, NULL, NULL, NULL, FALSE, TRUE);
}
else {
$links[$lang]= $longname;
}
}
}
else {
foreach ($languages as $lang => $longname) {
if ($lang != $language) {
$links[$lang]= l($longname, $lang.'/'.$q, NULL, NULL, NULL, FALSE, TRUE);
}
else $links[$lang] = $longname;
}
}
}
return $links;
}
I gonna keep searching and trying!!
Really hope someone can help me out :)
#5