Sunday, April 18, 2010

Drupal: Invalid argument supplied for foreach

I was working with my Drupal installation the other day and ran into this bug. It was not that bad as it did not affect the working. However, it will display this warning on screen on the top of results:
warning: Invalid argument supplied for foreach() in /home/web/public_html/modules/views/theme/views-view-table.tpl.php on line 24
I tried to remember what did I change to have introduced this error. Then I found that I actually changed the way fields appeared in Table.
If you want to reproduce this warning have all but one field excluded from display. In this one field have all the fields listed in the order you want them to appear. I use table style in views because I like alternating colors in odd and even rows. In the table style's settings set all fields to appear in the column of any of the fields excluded from display. This will bring you this error. In order to get rid of this error make all your fields appear in separate (their own) columns in table style's settings. 

No comments:

Post a Comment