Hi guys. Just as I was scratching my head about this issue, I see that you release rc1, an hooray, I update it. Nonetheless, I still have the following:

I am trying to create a simple block view that randomly displays text taken from body of certain node types. Everything worked ok until at some point, the view was previewing good, the new block was displaying things as needed, until I see this error:

warning: Invalid argument supplied for foreach() in /home/hipo/public_html/sites/all/modules/views/theme/views-view-fields.tpl.php on line 22.

I have tried and looked over this in here and google, but I haven't found anything useful, as I see that this error message is a more general one. I am lost, because this is my first time trying views, and I have really struggled to figure out how to use views, because I could not find any tutorial on version 2 (by the way, excellent idea with the help system)

If would be very grateful if someone has the time to help, maybe we will also squash a bug with this occasion :) I am at your disposal with info and tryouts, if needed.

Best regards

Comments

merlinofchaos’s picture

Can you export the view you're having this trouble with?

Vially’s picture

Yes, of course. Here it is:

<p>$view = new view; $view-&gt;name = 'stiati'; $view-&gt;description = 'View pentru stiati ca'; $view-&gt;tag = ''; $view-&gt;view_php = ''; $view-&gt;base_table = 'node'; $view-&gt;is_cacheable = FALSE; $view-&gt;api_version = 2; $view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */ $handler = $view-&gt;new_display('default', 'Defaults', 'default'); $handler-&gt;override_option('fields', array( 'body' =&gt; array( 'label' =&gt; 'Body', 'exclude' =&gt; 1, 'id' =&gt; 'body', 'table' =&gt; 'node_revisions', 'field' =&gt; 'body', 'relationship' =&gt; 'none', ), )); $handler-&gt;override_option('filters', array( 'type' =&gt; array( 'operator' =&gt; 'in', 'value' =&gt; array( 'stiatica' =&gt; 'stiatica', ), 'group' =&gt; '0', 'exposed' =&gt; FALSE, 'expose' =&gt; array( 'operator' =&gt; FALSE, 'label' =&gt; '', ), 'id' =&gt; 'type', 'table' =&gt; 'node', 'field' =&gt; 'type', 'relationship' =&gt; 'none', ), )); $handler-&gt;override_option('access', array( 'type' =&gt; 'none', 'role' =&gt; array(), 'perm' =&gt; '', )); $handler-&gt;override_option('title', 'Stiati ca...'); $handler-&gt;override_option('items_per_page', 1); $handler-&gt;override_option('use_more', 1); $handler = $view-&gt;new_display('block', 'Block', 'block_1');</p>

Thanks :)

P.S. The error looks exactly like this: warning: Invalid argument supplied for foreach() in /home/hipo/public_html/sites/all/modules/views/theme/views-view-fields.tpl.php on line 22.

Vially’s picture

Title: Getting "Invalid argument supplied for foreach() in... line 22" error in beta 4 and now rc1 » Getting "Invalid argument supplied for [... ]line 22" error in beta 4 and now rc1
merlinofchaos’s picture

Can you turn off your wysiwyg and re-export? It messes up the formatting.

merlinofchaos’s picture

Title: Getting "Invalid argument supplied for [... ]line 22" error in beta 4 and now rc1 » Getting "Invalid argument supplied for foreach() in... line 22" error in beta 4 and now rc1

You only have one field, the body field, and it's marked 'exclude'. That seems unwanted.

Vially’s picture

Thanks for helping. I have re-exported the view without wysiwyg. The error is still there, even though I have unmarked exclude for the field...

$view = new view;
$view->name = 'stiati';
$view->description = 'View pentru stiati ca';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'body' => array(
    'label' => 'Body',
    'exclude' => 0,
    'id' => 'body',
    'table' => 'node_revisions',
    'field' => 'body',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'stiatica' => 'stiatica',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
  'role' => array(),
  'perm' => '',
));
$handler->override_option('title', 'Stiati ca...');
$handler->override_option('items_per_page', 1);
$handler->override_option('use_more', 1);
$handler = $view->new_display('block', 'Block', 'block_1');
Vially’s picture

Status: Active » Fixed

I have reinstalled the module, and it didn't help, but I also deleted the view and recreated it 2 times, using different orders of creating it, and the second time it worked. I have the module up and running, and the view is ok. This can be closed for now.

Thanks for helping :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

ass45sin’s picture

Version: 6.x-2.0-rc1 » 6.x-2.7

I had this same problem.. views work out great during preview and my tests but users without proper permission can't see anything and the error message comes out. Had to give permission for users to see the content of the table created with views. Other style would just show pagers if any.

May this help other users.