Problem theming a view

antoine_ - June 26, 2008 - 18:04
Project:Views
Version:6.x-2.0-beta4
Component:page displays
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

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
<?php
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...

#1

merlinofchaos - June 26, 2008 - 20:07
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.

#2

antoine_ - June 26, 2008 - 22:10

Yes it worked, thank you. Sorry for asking.

#3

Anonymous (not verified) - July 10, 2008 - 22:14
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.