foreach() HAXS
Fusion_Sushi - February 5, 2006 - 10:31
| Project: | Dashboard |
| Version: | 4.7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
warning: Invalid argument supplied for foreach() in drive\path\modules\dashboard\dashboard.module on line 227.
???

#1
When using this tutorial (http://www.logrus.com/dashboard/readme) on the Dashboards:
Placing a list of node teasers in a panel:
The function dashboard_get_node_list() is a quick shortcut to make this a little easier. Simply pass it an array of already loaded nodes (not just NIDs). You can use this to create quick-and-easy two column teaser displays:
(Stealing the query from node_page_default() which is the query used to print the normal Drupal front page nodes)
Put this in the LEFT section:
<?php$result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));
if (db_num_rows($result)) {
$output = '';
$count = 0;
global $rightList;
while ($node = db_fetch_object($result)) {
$count++;
if ($count % 2 == 0)
$rightList[] = node_load(array('nid' => $node->nid));
else
$leftList[] = node_load(array('nid' => $node->nid));
}
}
print dashboard_get_node_list($leftList, TRUE);
?>
Put this in the RIGHT section:
<?phpprint dashboard_get_node_list($rightList, TRUE);
?>
Put this in the BOTTOM section:
<?phpprint theme('pager', NULL, variable_get('default_nodes_main', 10));
?>
#2
This is an ugly fix:
Left:
<?php$result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 6));
if (db_num_rows($result)) {
$output = '';
$count = 0;
global $rightList;
while ($node = db_fetch_object($result)) {
$count++;
if ($count % 2 == 0)
$rightList2[] = node_load(array('nid' => $node->nid));
else
$leftList[] = node_load(array('nid' => $node->nid));
}
}
print dashboard_get_node_list($leftList, TRUE);
?>
Right:
<?php$result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 6));
if (db_num_rows($result)) {
$output = '';
$count = 0;
global $rightList;
while ($node = db_fetch_object($result)) {
$count++;
if ($count % 2 == 0)
$rightList[] = node_load(array('nid' => $node->nid));
else
$leftList2[] = node_load(array('nid' => $node->nid));
}
}
print dashboard_get_node_list($rightList, TRUE);
?>
#3
Um. Try putting a 'global $rightList' in the right-hand section.
#4
Umm, nope that does not do it. This code, which is listed as a turorial does not work in 4.7.. if someone has a version that does work, I'd love to see it.
#5
Like the predecessor, I get the error:
warning: Invalid argument supplied for foreach() in /var/www/vhosts/mydomain.com/httpdocs/drupal/modules/dashboard/dashboard.module on line 227.
I get this when I insert the sample Dashboard code into my left and right columns. It doesn't seem to like the right column.
#6