I created a views page to display a taxonomy term view using the "Panels: Teasers 1 top + 3 columns". When viewing a term with only 1 node assoiciated to it I got the following error.

warning: Invalid argument supplied for foreach() in \sites\all\modules\views_bonus\views_bonus_panels.module on line 37.

I fixed it by adding an is_array check before the foreach statement.

   if(is_array($items)){ // ** added is_array to stop foreach attempting to process 0 item array.
      foreach ($items as $item) {
        switch ($count % $cols) {
          case 0:
            $section = 'left';
            break;
          case 1:
            if($cols == 2) {
              $section = 'right';
            }
            else {
              $section = 'middle';
            }
            break;
          case 2:
            $section = 'right';
            break;
        }
        $content[$section] .= $item;
        $count++;
      }
    } //

Comments

dmitrig01’s picture

Assigned: Unassigned » dmitrig01
Category: task » bug
Priority: Normal » Minor
Status: Fixed » Active

Gonna patch this soon

dmitrig01’s picture

Status: Active » Closed (duplicate)