error when using default Row Style Output

cpelham - July 4, 2008 - 20:08
Project:Views
Version:6.x-2.0-rc1
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Using Views theming information, I created a theme file called vews-view-fields--events--default.tpl.php and pasted into it the default text presented by the Views Theme information for Row Style Output, with no edits. I then uploaded that file into sites/all/themes/zen/zen.

Now when I look at live preview of my view, I get the following error:
warning: Invalid argument supplied for foreach() in /home/crsnyorg/public_html/guidotuveri.com/drupal/sites/all/themes/zen/zen/views-view-fields--events--default.tpl.php on line 22.

Line 22 is:

<?php
foreach ($fields as $id => $field):
?>

Ultimately, I want to modify this file so that some of the field labels are not printed. It was clear how to do this in Drupal 5. But I am less sure how to do it here as there do not seem to be any specific instructions for how to do so. The sample script here loops through all the fields and treats them all the same.

The whole script is:

<?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 $id => $field):
?>

<?php
if (!empty($field->separator)):
?>

<?php
print $field->separator;
?>

<?php
endif;
?>

<

<?php
print $field->inline_html;
?>
class="views-field-
<?php
print $field->class;
?>
">
<?php
if ($field->label):
?>

<?php
print $field->label;
?>
:

<?php
endif;
?>

<?php
print $field->content;
?>

<?php
endforeach;
?>

#1

merlinofchaos - July 4, 2008 - 20:16
Status:active» fixed

You need to use the latest Drupal 6.x-dev, as the release announcement states. And the release notes. And a note in the help available on the Theme: Information page.

#2

Anonymous (not verified) - July 23, 2008 - 10:56
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.