I have a page grid with 5 columns. When it has six items there is only one TD for the second row which makes the grid look like this:

Firefox 3.0.10
+----+----+----+----+----+
|    |    |    |    |    |
|    |    |    |    |    |
+----+----+    |    |    |
|    |    |    |    |
|    |    |    |    |
+----+    

IE8
+----+----+----+----+----+
|    |    |    |    |    |
|    |    |    |    |    |
+----+----+----+----+----+
|    |
|    |
+----+    

I want it to display all 5 cells on both rows, even if it will be 4 empty ones on row 2.

I suppose this is a bug...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mstef’s picture

Version: 6.x-2.5 » 6.x-2.6

+1...

definitely should be fixed...

not sure how to do it yet but i'll look now

dawehner’s picture

FileSize
685 bytes

Here is an initial patch, but it works only for horizontal grids currently.

mstef’s picture

nice work dereine..works perfectly...i looked at it quickly and couldn't figure it out at first..

thanks

dawehner’s picture

But this does not fix the vertical display of the grid style.

superbaloo’s picture

Status: Active » Needs review
FileSize
1.14 KB

Here is a patch for both vertical and horizontal,

Including the dereine's one :)

mstef’s picture

looks good...nice work too

dawehner’s picture

Status: Needs review » Active

But this does not fix the vertical display of the grid style.

dawehner’s picture

Status: Active » Needs review

damn, there was something in my browser cache since this afternoon.

+++ theme/theme.inc	3 Sep 2009 18:07:11 -0000
@@ -425,6 +432,10 @@ function template_preprocess_views_view_
     }
+    for ($i = 0; $i < count($rows[1]); $i++) {

Why $rows[1] and not $rows[0].

+++ theme/theme.inc	3 Sep 2009 18:07:11 -0000
@@ -425,6 +432,10 @@ function template_preprocess_views_view_
+      $rows[count($rows) - 1][$i] .= '';

I would use only "=" here

I'm on crack. Are you, too?

superbaloo’s picture

FileSize
1.17 KB

Sorry for this, you were right :)

dawehner’s picture

+++ theme/theme.inc	3 Sep 2009 20:38:24 -0000
@@ -425,6 +432,12 @@ function template_preprocess_views_view_
+      if (empty($rows[count($rows) - 1][$i])) {

If the item is "0" this will return TRUE and replaced with ''.

This review is powered by Dreditor.

dawehner’s picture

Status: Needs review » Needs work

needs work :)

superbaloo’s picture

Status: Needs work » Needs review
FileSize
1.17 KB

Lol !

here it's fixed !

sorry for useless iterations

superbaloo’s picture

FileSize
1.2 KB

Patch seems not to apply, don't know why ...

Here is a patched version ! :p

dawehner’s picture

I would think thats its rtbc, if its not by design ;)

I think tables has to be completed, so fixing this would be good.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Note ++ is a unary operator and therefore shouldn't have had a space.

mstef’s picture

Status: Fixed » Needs work

Everything works great with this patch besides one thing...

If there is only one row in the grid output, the patch now causes it to add additional empty td's. This is only necessary if there is more than one row.

merlinofchaos’s picture

Status: Needs work » Active

Better make it active. 'needs work' can be kind of a wasteland if no one is specificly working on it.

joanpc’s picture

I don't like empty cells unless they have an empty class or something to make them disappear from CSS

leducmills’s picture

FileSize
186.2 KB

Is it possible that this could be causing empty cells to show up on grid views? (see attached -- notice the last two cells) Just happened when I updated to the latest views version.

Any fixes to get rid of this? I just want blank space.

Thanks!

joanpc’s picture

yes It does!

I fixed similar issue making a custom views template to not display empty cells.

views-view-grid.tpl.php

<?php
// $Id: views-view-grid.tpl.php,v 1.3 2008/06/14 17:42:43 merlinofchaos Exp $
/**
 * @file views-view-grid.tpl.php
 * Default simple view template to display a rows in a grid.
 *
 * - $rows contains a nested array of rows. Each row contains an array of
 *   columns.
 *
 * @ingroup views_templates
 */
?>
<?php if (!empty($title)) : ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<table class="views-view-grid">
  <tbody>
    <?php foreach ($rows as $row_number => $columns): ?>
      <?php
        $row_class = 'row-' . ($row_number + 1);
        if ($row_number == 0) {
          $row_class .= ' row-first';
        }
        elseif (count($rows) == ($row_number + 1)) {
          $row_class .= ' row-last';
        }
      ?>
      <tr class="<?php print $row_class; ?>">
        <?php foreach ($columns as $column_number => $item): ?>
          <?php if ($item):?>
	   <td class="<?php print 'col-'. ($column_number + 1); ?>">
            <?php print $item; ?>
          </td>
          <?php endif ?>
        <?php endforeach; ?>
      </tr>
    <?php endforeach; ?>
  </tbody>
</table>

IMHO: No displaying empty cells is ok. Firefox don't know how to display these kind of tables, is a firefox bug. But you can fix the borders with some css.

IE and Safari display these tables well.

Bilmar’s picture

subscribing

joanpc’s picture

Maybe the best way is to add an option to enable/disable displaying empty cells in the grid style config of the view.

It will be useful to have the both options. Without forgetting to add some kind of "empty-cell" css class to empty cells.

but that's a feature request..

dawehner’s picture

Status: Active » Needs review
FileSize
487 bytes

Here is a patch which fixes this

merlinofchaos’s picture

Status: Needs review » Fixed

Fix committed to all branches. Thanks dereine!

Status: Fixed » Closed (fixed)

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