Panels sorted by column (not alternating) + even/odd rows

Created on 4 April 2011, almost 14 years ago
Updated 8 March 2023, almost 2 years ago

Just came with this solution for a project I am currently working on.
This will sort columns like this

a  d  g
b  e  h
c  f

and add alternating even/odd classes to rows.

I'm not crafty enough to make a patch and tought maybe you can use this code and add an option somewhere for this display variant.

To make it work replace the entire last foreach loop in views_bonus_panel.module with the code below

  $splitPoint = ceil(count($rows)/$columns);
  $rowclass = "";
  
  foreach ($rows as $offset => $row) {
	$rowclass = ($offset%2 == 0) ? "views-row views-row-even" : "views-row views-row-odd";
	if ($offset <= $splitPoint) {
	  $x = 0;
    } elseif ($offset <= 2*$splitPoint) {
	  $x = 1;
	} else {
	  $x = 2;
    }
	$content[$col_names[$x]] .= "<div class='{$rowclass}'>" . $row . "</div>";
  }
✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡·πŸ‡ΈSerbia dizarter

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024