Views grid style output template views-view-grid.tpl.php

Public

Changes tabular output style grid

Get raw version
php
  1. <?php
  2.  
  3. /**
  4.  * @file
  5.  * Default simple view template to display a rows in a grid.
  6.  *
  7.  * - $rows contains a nested array of rows. Each row contains an array of
  8.  * columns.
  9.  *
  10.  * @ingroup views_templates
  11.  */
  12. $_grid = array();
  13. ?>
  14. <?php if (!empty($title)) : ?>
  15. <h3><?php print $title; ?></h3>
  16. <?php endif; ?>
  17. <div class="<?php print $class; ?> clearfix"<?php print $attributes; ?>>
  18. <?php foreach ($rows as $row_number => $columns): ?>
  19. <?php foreach ($columns as $column_number => $item): ?>
  20. <?php $_grid[$column_number][$row_number] = $item; ?>
  21. <?php endforeach; ?>
  22. <?php endforeach; ?>
  23.  
  24. <?php foreach ($_grid as $column_number => $_items): ?>
  25. <?php if (count($_grid[$column_number]) != count($row_classes)) { $row_classes[count($_grid[$column_number])-1] .= ' row-last' ; } ?>
  26.  
  27.  
  28. <div <?php if ($column_classes[0][$column_number]) { print 'class="' . $column_classes[0][$column_number] .' col"'; } ?>>
  29. <?php foreach($_grid[$column_number] as $row_number => $_item): ?>
  30. <div <?php if ($row_classes[$row_number]) { print 'class="' . $row_classes[$row_number] .'"'; } ?>>
  31. <?php print $_item; ?>
  32. </div>
  33. <?php endforeach; ?>
  34. </div>
  35. <?php endforeach; ?>
  36. </div>