I created a view that places a series of thumbnail pics along with a link (title & url) into a table with 3 columns. The preview of the view looks fine. I placed the view block into my rightside bar and received the following error:

warning: Invalid argument supplied for foreach() in sites/all/modules/views/theme/views-view-table.tpl.php on line 24.

I'm not sure whether this is a Views or CCK issue, so I have posted here.

< ?php
$view = new view; $view->name = 'Video_Thumb_Links'; $view->description = 'View of the IFV Video Thumbnail Pics & Links for Right Sidebar'; $view->tag = 'Video Thumb Links'; $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( 'field_videopic1_fid' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'link_to_node' => 0, 'label_type' => 'custom', 'format' => 'image_imagelink', 'multiple' => array( 'group' => TRUE, 'multiple_number' => '', 'multiple_from' => '', 'multiple_reversed' => FALSE, ), 'exclude' => 0, 'id' => 'field_videopic1_fid', 'table' => 'node_data_field_videopic1', 'field' => 'field_videopic1_fid', 'relationship' => 'none', ), 'field_videolink1_url' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'link_to_node' => 0, 'label_type' => 'custom', 'format' => 'default', 'multiple' => array( 'group' => TRUE, 'multiple_number' => '', 'multiple_from' => '', 'multiple_reversed' => FALSE, ), 'exclude' => 0, 'id' => 'field_videolink1_url', 'table' => 'node_data_field_videolink1', 'field' => 'field_videolink1_url', 'relationship' => 'none', ), 'field_videopic2_fid' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'link_to_node' => 0, 'label_type' => 'custom', 'format' => 'image_imagelink', 'multiple' => array( 'group' => TRUE, 'multiple_number' => '', 'multiple_from' => '', 'multiple_reversed' => FALSE, ), 'exclude' => 0, 'id' => 'field_videopic2_fid', 'table' => 'node_data_field_videopic2', 'field' => 'field_videopic2_fid', 'relationship' => 'none', ), 'field_videolink2_url' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'link_to_node' => 0, 'label_type' => 'custom', 'format' => 'default', 'multiple' => array( 'group' => TRUE, 'multiple_number' => '', 'multiple_from' => '', 'multiple_reversed' => FALSE, ), 'exclude' => 0, 'id' => 'field_videolink2_url', 'table' => 'node_data_field_videolink2', 'field' => 'field_videolink2_url', 'relationship' => 'none', ), 'field_videopic3_fid' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'link_to_node' => 0, 'label_type' => 'custom', 'format' => 'image_imagelink', 'multiple' => array( 'group' => TRUE, 'multiple_number' => '', 'multiple_from' => '', 'multiple_reversed' => FALSE, ), 'exclude' => 0, 'id' => 'field_videopic3_fid', 'table' => 'node_data_field_videopic3', 'field' => 'field_videopic3_fid', 'relationship' => 'none', ), 'field_videolink3_url' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'link_to_node' => 0, 'label_type' => 'custom', 'format' => 'default', 'multiple' => array( 'group' => TRUE, 'multiple_number' => '', 'multiple_from' => '', 'multiple_reversed' => FALSE, ), 'exclude' => 0, 'id' => 'field_videolink3_url', 'table' => 'node_data_field_videolink3', 'field' => 'field_videolink3_url', 'relationship' => 'none', ), )); $handler->override_option('sorts', array( 'status' => array( 'id' => 'status', 'table' => 'node', 'field' => 'status', ), 'created' => array( 'order' => 'ASC', 'granularity' => 'second', 'id' => 'created', 'table' => 'node', 'field' => 'created', 'relationship' => 'none', ), )); $handler->override_option('filters', array( 'type' => array( 'operator' => 'in', 'value' => array( 'video_thumb_pic' => 'video_thumb_pic', ), 'group' => '0', 'exposed' => FALSE, 'expose' => array( 'operator' => FALSE, 'label' => '', ), 'id' => 'type', 'table' => 'node', 'field' => 'type', 'relationship' => 'none', ), )); $handler->override_option('access', array( 'type' => 'none', )); $handler->override_option('title', 'IFV Videos'); $handler->override_option('use_pager', '1'); $handler->override_option('use_more', 1); $handler->override_option('style_plugin', 'table'); $handler->override_option('style_options', array( 'grouping' => '', 'override' => 1, 'sticky' => 0, 'order' => 'asc', 'columns' => array( 'field_videopic1_fid' => 'field_videopic1_fid', 'field_videolink1_url' => 'field_videopic1_fid', 'field_videopic2_fid' => 'field_videopic2_fid', 'field_videolink2_url' => 'field_videopic2_fid', 'field_videopic3_fid' => 'field_videopic3_fid', 'field_videolink3_url' => 'field_videopic3_fid', ), 'info' => array( 'field_videopic1_fid' => array( 'separator' => '
', ), 'field_videolink1_url' => array( 'sortable' => 0, 'separator' => '', ), 'field_videopic2_fid' => array( 'separator' => '
', ), 'field_videolink2_url' => array( 'sortable' => 0, 'separator' => '', ), 'field_videopic3_fid' => array( 'separator' => '
', ), 'field_videolink3_url' => array( 'sortable' => 0, 'separator' => '', ), ), 'default' => '-1', )); $handler->override_option('row_options', array( 'inline' => array(), 'separator' => '', )); $handler = $view->new_display('block', 'Block', 'block_1'); $handler->override_option('items_per_page', 3); $handler->override_option('block_description', ''); $handler->override_option('block_caching', -1); $handler = $view->new_display('page', 'Page', 'page_1'); $handler->override_option('path', 'content/video-thumbpic-links'); $handler->override_option('menu', array( 'type' => 'none', 'title' => '', 'description' => '', 'weight' => 0, 'name' => 'navigation', )); $handler->override_option('tab_options', array( 'type' => 'none', 'title' => '', 'description' => '', 'weight' => 0, )); ?>

SELECT node.nid AS nid,
   node_data_field_videopic1.field_videopic1_fid AS node_data_field_videopic1_field_videopic1_fid,
   node_data_field_videopic1.field_videopic1_list AS node_data_field_videopic1_field_videopic1_list,
   node_data_field_videopic1.field_videopic1_data AS node_data_field_videopic1_field_videopic1_data,
   node.type AS node_type,
   node.vid AS node_vid,
   node_data_field_videopic1.field_videolink1_url AS node_data_field_videopic1_field_videolink1_url,
   node_data_field_videopic1.field_videolink1_title AS node_data_field_videopic1_field_videolink1_title,
   node_data_field_videopic1.field_videolink1_attributes AS node_data_field_videopic1_field_videolink1_attributes,
   node_data_field_videopic1.field_videopic2_fid AS node_data_field_videopic1_field_videopic2_fid,
   node_data_field_videopic1.field_videopic2_list AS node_data_field_videopic1_field_videopic2_list,
   node_data_field_videopic1.field_videopic2_data AS node_data_field_videopic1_field_videopic2_data,
   node_data_field_videopic1.field_videolink2_url AS node_data_field_videopic1_field_videolink2_url,
   node_data_field_videopic1.field_videolink2_title AS node_data_field_videopic1_field_videolink2_title,
   node_data_field_videopic1.field_videolink2_attributes AS node_data_field_videopic1_field_videolink2_attributes,
   node_data_field_videopic1.field_videopic3_fid AS node_data_field_videopic1_field_videopic3_fid,
   node_data_field_videopic1.field_videopic3_list AS node_data_field_videopic1_field_videopic3_list,
   node_data_field_videopic1.field_videopic3_data AS node_data_field_videopic1_field_videopic3_data,
   node_data_field_videopic1.field_videolink3_url AS node_data_field_videopic1_field_videolink3_url,
   node_data_field_videopic1.field_videolink3_title AS node_data_field_videopic1_field_videolink3_title,
   node_data_field_videopic1.field_videolink3_attributes AS node_data_field_videopic1_field_videolink3_attributes,
   node.status AS node_status,
   node.created AS node_created
 FROM node node 
 LEFT JOIN content_type_video_thumb_pic node_data_field_videopic1 ON node.vid = node_data_field_videopic1.vid
 WHERE node.type in ('video_thumb_pic')
   ORDER BY node_status ASC, node_created ASC

Any help is much appreciated.Thanks!

Comments

SDM-MINK’s picture

Can anyone provide assistance regarding this matter?

jamesmcd’s picture

Just had the same sites/all/modules/views/theme/views-view-table.tpl.php on line 24.

Any luck on a resolution for this?

bdimofte’s picture

I've just had the same problem, the theme tried to access undefined variables ($header is the one at line 24). I realized that happened only for some user roles. So, I went to the "user permissions" page and there it was... I had a lot of "view field_x" checked only for admin.
Look there, maybe you've been as absent-minded as I've been :)

jamesmcd’s picture

Yes, I realised this when I signed out and noticed some of the data wasn't showing up in the views I had created.

Thanks for clarifying!

Ashford’s picture

Status: Active » Fixed

Searching and noticed this problem was solved. Tagged it as fixed. I hope that is helping and not over stepping my bounds as a generalized Drupal Forum member.

Status: Fixed » Closed (fixed)

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

seanenroute’s picture

To clarify for anyone coming to this page later. More than likely you just enabled the 'Content Permissions' module. It automatically sets the cck fields to viewable by admin only. The solution is to go to 'user permissions' and enable the cck fields to viewable.

Happy Drupaling ^^

luco’s picture

actually, I found out this can also be caused if you don't use content permissions - like me.

in my table I was placing all fields in the same column - which was excluded from display since it was a grouping field.

as it turns out it was a misconception of mine. I was supposed to have a grouping field, but each field in its own column. in this way I could safely exclude one of them from display. plus the table looks neater now ;]

btw my example is a table for the weekly schedule of a gym. so there's columns for days and each day has classes organised by time, type of exercise and teacher.

hope this helps. and like seanenroute pointed out, "Happy Drupaling ^^"

bryanb229’s picture

This seems to still be happening to me despite disabling content permissions and trying to code it out with CSS instead of excluding from the views display.

It's really taxing my error logs.

Working hard to find a solution asap, will update this post as needed.

Anyone that has any insight would be much appreciated.

jaydaley’s picture

I encountered it when I put all my fields into one column in a table view and fixed it by splitting it into three columns, the first one of which is for a non-viewable field.

tmsimont’s picture

Status: Closed (fixed) » Active

this isn't fixed -- i'm seeing the same thing. i get it when putting 3 field values into 1 cell of a table output. I don't have content permisssions nor do i have field level permissions.

i read here that you can fix it by splitting the values into their own columns, but that seems like a bug to me if the settings that should work (grouping multiple fields into a single cell) create errors.

it may be related to the fact that some nodes don't have the field i'm trying to show. if this is the case, there shouldn't be an error. looks like there needs to be an isset() check in here somewhere.

tmsimont’s picture

Status: Active » Needs review

drop this in your theme folder (perhaps views should be shipped with this?)

views-view-table.tpl.php:

<?php
// $Id: views-view-table.tpl.php,v 1.8 2009/01/28 00:43:43 merlinofchaos Exp $
/**
 * @file views-view-table.tpl.php
 * Template to display a view as a table.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $header: An array of header labels keyed by field id.
 * - $fields: An array of CSS IDs to use for each field id.
 * - $class: A class or classes to apply to the table, based on settings.
 * - $row_classes: An array of classes to apply to each row, indexed by row
 *   number. This matches the index in $rows.
 * - $rows: An array of row items. Each row is an array of content.
 *   $rows are keyed by row number, fields within rows are keyed by field ID.
 * @ingroup views_templates
 */
?>
<table class="<?php print $class; ?>">
  <?php if (!empty($title)) : ?>
    <caption><?php print $title; ?></caption>
  <?php endif; ?>
  <thead>
    <tr>
	  <?php if(isset($header) && is_array($header)): ?>
      <?php foreach ($header as $field => $label): ?>
        <th class="views-field views-field-<?php print $fields[$field]; ?>">
          <?php print $label; ?>
        </th>
      <?php endforeach; ?>
	  <?php endif; ?>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($rows as $count => $row): ?>
      <tr class="<?php print implode(' ', $row_classes[$count]); ?>">
        <?php foreach ($row as $field => $content): ?>
          <td class="views-field views-field-<?php print $fields[$field]; ?>">
            <?php print $content; ?>
          </td>
        <?php endforeach; ?>
      </tr>
    <?php endforeach; ?>
  </tbody>
</table>

?>
laraz’s picture

The problem is because the user don't have permission in the fields that want to see in the view.

Anonymous’s picture

#12 fixed it for me. Thanks!

dawehner’s picture

Version: 6.x-2.5 » 6.x-2.x-dev
Status: Needs review » Postponed (maintainer needs more info)

Update status.

Does someone know whether this still applies to 2.x-dev? As far as i remember there was a similar issue for views3, and it got fixed there already.

esmerel’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)