views-view-fields.tpl.php

  1. 3.x theme/views-view-fields.tpl.php
  2. 2.x theme/views-view-fields.tpl.php

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.

File

theme/views-view-fields.tpl.php
View source
  1. <?php
  2. /**
  3. * @file views-view-fields.tpl.php
  4. * Default simple view template to all the fields as a row.
  5. *
  6. * - $view: The view in use.
  7. * - $fields: an array of $field objects. Each one contains:
  8. * - $field->content: The output of the field.
  9. * - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
  10. * - $field->class: The safe class id to use.
  11. * - $field->handler: The Views field handler object controlling this field. Do not use
  12. * var_export to dump this object, as it can't handle the recursion.
  13. * - $field->inline: Whether or not the field should be inline.
  14. * - $field->inline_html: either div or span based on the above flag.
  15. * - $field->separator: an optional separator that may appear before a field.
  16. * - $row: The raw result object from the query, with all data it fetched.
  17. *
  18. * @ingroup views_templates
  19. */
  20. ?>
  21. <?php foreach ($fields as $id => $field): ?>
  22. <?php if (!empty($field->separator)): ?>
  23. <?php print $field->separator; ?>
  24. <?php endif; ?>
  25. <<?php print $field->inline_html;?> class="views-field-<?php print $field->class; ?>">
  26. <?php if ($field->label): ?>
  27. <label class="views-label-<?php print $field->class; ?>">
  28. <?php print $field->label; ?>:
  29. </label>
  30. <?php endif; ?>
  31. <?php
  32. // $field->element_type is either SPAN or DIV depending upon whether or not
  33. // the field is a 'block' element type or 'inline' element type.
  34. ?>
  35. <<?php print $field->element_type; ?> class="field-content"><?php print $field->content; ?></<?php print $field->element_type; ?>>
  36. </<?php print $field->inline_html;?>>
  37. <?php endforeach; ?>

Related topics