You are here

24 February 2016

You can use "group by" in views to group data by a field. When you start writing css for it, or even use accordion. You need to wrap the rows into a container. This can be achieved by creating a template file(views-view-unformatted--my-view.tpl.php) and changing it accordingly.

Source code viewer
  1. <?php if (!empty($title)): ?>
  2. <!-- This is the group title. -->
  3. <h3><?php print $title; ?></h3>
  4. <?php endif; ?>
  5. <!-- Add your wrapper element. -->
  6. <div class="group-wrapper">
  7. <?php foreach ($rows as $id => $row): ?>
  8. <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"'; } ?>>
  9. <?php print $row; ?>
  10. </div>
  11. <?php endforeach; ?>
  12. <!-- Close your wrapper element. -->
  13. </div>
Programming Language: PHP