Hello,
I am using Drupal 6 and Views 2. A made a view listing nodes of a specific content content type, but only some fields.
I want to theme this view so I created a views-view-fields--VIEWNAME.tpl.php. Basically, I copied/pasted the code given by views for this field to see if it worked. And it did not...
I get the following error message when trying to display my view :

* warning: Invalid argument supplied for foreach() in /home/antoine/Work/www/perso/sites/all/themes/celju/views-view-fields--articles-all.tpl.php on line 23.
* warning: Invalid argument supplied for foreach() in /home/antoine/Work/www/perso/sites/all/themes/celju/views-view-fields--articles-all.tpl.php on line 23.
* warning: Invalid argument supplied for foreach() in /home/antoine/Work/www/perso/sites/all/themes/celju/views-view-fields--articles-all.tpl.php on line 23.

My code in views-view-fields--VIEWNAME.tpl.php is the following :

<?php
// $Id: views-view-fields.tpl.php,v 1.5 2008/05/05 23:51:47 merlinofchaos Exp $
/**
* @file views-view-fields.tpl.php
* Default simple view template to all the fields as a row.
*
* - $view: The view in use.
* - $fields: an array of $field objects. Each one contains:
*   - $field->content: The output of the field.
*   - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
*   - $field->class: The safe class id to use.
*   - $field->handler: The Views field handler object controlling this field. Do not use
*     var_export to dump this object, as it can't handle the recursion.
*   - $field->inline: Whether or not the field should be inline.
*   - $field->inline_html: either div or span based on the above flag.
*   - $field->separator: an optional separator that may appear before a field.
* - $row: The raw result object from the query, with all data it fetched.
*
* @ingroup views_templates
*/
?>

<?php foreach ($fields as $field): ?>
  <?php if (!empty($field->separator)): ?>
    <?php print $field->separator; ?>
  <?php endif; ?>

  <<?php print $field->inline_html;?> class="views-field-article-<?php print $field->class; ?>">
    <?php if ($field->label): ?>
      <label class="views-label-article-<?php print $field->class; ?>">
        <?php print $field->label; ?>:
      </label>
    <?php endif; ?>
      <span class="field-content-article-"><?php print $field->content; ?></span>
  </<?php print $field->inline_html;?>>
<?php endforeach; ?>

Line 23 is

foreach ($fields as $field):

Everything seems right, I copied the code from the views module. Do you have any idea why it does not work ?
I saw the bug with theming, but there seem to have no link with it...

Comments

merlinofchaos’s picture

Status: Active » Fixed

As mentioned in the help link on the theme: information page, you need to be running Drupal 6.3 (and since 6.3 isn't out yet, use Drupal 6.x-dev); there is a bug in Drupal core.

antoine_’s picture

Yes it worked, thank you. Sorry for asking.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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