Hi,

I noticed that records for empty fields are not completely hidden from a table, even if the view is configured with the settings "Hide if empty" and "Count the number 0 as empty": The field label is displayed anyway. This happens as well for taxonomy terms as for CCK fields.

This (probably unwanted) behaviour disturbes the layout and might irritate the user; however, the table display from Views2 behaves identically and comments:

Note that the field label may still be displayed. Check style or row style settings to hide labels for empty fields.

Neither the "Flipped table" display style nor the Views core "Table" display style provide such row style settings to completely hide empty field records.

Since "Flipped table" behaves identical to Views core I'm unsure if this is really a bug; but, whatever this is worth, at least I dislike this behaviour because I'd expect that the "Hide if empty" setting would really hide empty records.

If you don't consider this a bug, feel free to change this issue's category to a feature request.

Thank you!, -asb

CommentFileSizeAuthor
#1 flipped-table.jpeg25.28 KBasb

Comments

asb’s picture

StatusFileSize
new25.28 KB

Screenshot attached for illustrative purposes. This flipped table includes three rows for taxonomy vocabularies from which two are empty ("Akteure", "Galerie").

infojunkie’s picture

If I understand you correctly, you want to hide the whole row if the field values for all results are empty, right?

asb’s picture

Yes, exactly. Imho, if there is no value for a field or a vocabulary, there should be an option to exclude irrelevant elements (like field titles), e.g. a checkbox at the row style settings similar to that one for "HTML list":

Hide empty fields:
Do not display fields, labels or markup for fields that are empty.
asb’s picture

Title: Hide if empty doesn't hide the field label » Make "Hide if empty" fully collapsible
Category: bug » feature

Sounds related: #1011650: Hide if empty isn't working on some of my views, but does on others.

Changing title to a (hopefully) better description.

nitebreed’s picture

Subscribing

acdtrp’s picture

If you use "HTML List" not a Table it hides the empty labels as wishes... but it doesn't work in tables, which sucks very much :)

iprosp’s picture

I had the same issue and i solved it by doing the following changes to views-flipped-table-tpl.php
(Latest Dev Version)

I changed this:

<tbody>
    <?php foreach ($row as $field => $rowname) : ?>
      <?php if ($field != 'title') : ?>
      <tr class="<?php print $element; ?>">
        <th>
          <?php print $header[$field]; ?>
        </th>
      <?php foreach ($rowname as $count => $item): ?>
        <td>
          <?php print $item; ?>
        </td>
      <?php endforeach; ?>
      </tr>
      <?php
        if ($element == 'odd'){
          $element = 'even';
        } else {
          $element = 'odd';
        }
      ?>
      <?php endif; // field != title ?>
    <?php endforeach; ?>
  </tbody>

To this:

<tbody>
    <?php foreach ($row as $field => $rowname) : ?>
      <?php if ($field != 'title') : ?>
	  
	  <?php foreach ($rowname as $count => $item): ?>
	  <?php if(!empty($item)) { ?>
		  <tr class="<?php  print $element; ?>">
			<th>
			  <?php print $header[$field]; ?>
			</th>
			<td>
			  <?php print $item; ?>
			</td>
		  </tr>
	  <?php } endforeach; ?>
      <?php
        if ($element == 'odd'){
          $element = 'even';
        } else {
          $element = 'odd';
        }
      ?>
      <?php endif; // field != title ?>
    <?php endforeach; ?>
  </tbody>

Hope it helps!

asb’s picture

Status: Active » Reviewed & tested by the community

This is absolutelely amazing, it's exactly the feature I imagined. Also, it's working as well with 6.x-1.0-beta2.

I did some testing, and as far as I can tell there are no side effects. Maybe we could get this in the dev version?

Many thanks, jackpros!

iprosp’s picture

I don't think that it can be committed, because it will hide an empty line regardless of your choice('hide empty field') and i don't know how to read the field setting correctly and add it to the 'if'.

asb’s picture

I'm not sure if this is really a problem; the need for a listing with empty rows *and* empty fields appears a bit like an edge-case to me. To *not* display empty fields, I rewrote all empty fields to something like "N/A" or "not yet available" (which, btw, was a lot of fun after updating to Views 3 ;)

But probably It'd be a sound alternative to make an option in the UI available: E.g. a checkbox in the row style settings "Do not show empty rows", similar to what Views provides. This should cover all use cases, and if the checkbox would be unchecked by default, it'd not even modify the behaviour as it is now.

joachim’s picture

Status: Reviewed & tested by the community » Active

AFAICT this is now working on D7. Changing status as there's no patch for D6 here.

asb’s picture

Version: 6.x-1.0-beta1 » 7.x-1.x-dev

This issue is for D6, and the patch is working well for D6. Probably you mean "no patch for D7"? In this case we should also adjust the 'Views Hacks' version as well.

joachim’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev

No, I mean that AFAICT this is not a problem on D7, where what's described in this issue works correctly.

And I changed the status, because RTBC is the wrong status for this issue: there is no patch here to commit.

naught101’s picture

Project: Views Hacks » Views Flipped Table
Version: 6.x-1.x-dev » 7.x-1.x-dev
Component: Views Flipped Table » Code
naught101’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev

whoops

naught101’s picture

Status: Active » Closed (won't fix)

Sounds like this was fixed in views itself. Ideally, Views Flipped Table should follow Views' Table as closely as possible, so I would prefer not to include hacks for problems in views. If this is still a problem, and it's not occurring in the standard table view, feel free to re-open.

asb’s picture

Category: Feature request » Bug report
Issue summary: View changes
Status: Closed (won't fix) » Active

Reopening and marking #1479368: hide empty rows as duplicate.

karlshea’s picture

Status: Active » Closed (outdated)