Closed (works as designed)
Project:
Views (for Drupal 7)
Version:
6.x-2.8
Component:
User interface
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Jan 2010 at 17:24 UTC
Updated:
27 Jan 2011 at 17:11 UTC
Jump to comment: Most recent file
Comments
Comment #1
merlinofchaos commentedCheck the HTML. Is CCK putting HTML in there despite there being no actual value? If so, Views cannot distinguish between this non-printing HTML and no value. In that case, it would be a CCK issue.
Comment #2
dafederThanks Merlin. No, there doesn't appear to be any html in there. In the source, there's nothing after the tag and in devel both [raw] and [content] for those fields come up as 0 characters.
Comment #3
dafederHere is the export of a view on a test install of drupal, using the Garland theme, where I get labels on both empty CCK text fields and an empty node body.
Comment #4
svetlin commentedI had the same problem. When I deleted all markup from the field template, the label was hidden.
Comment #5
merlinofchaos commentedsvetlin's comment in #4 is consistent with what I said in #1.
Can you paste some actual HTML (be sure to use
<code>tags so the HTML doesn't get corrupted) output where the empty field is being displayed?Comment #6
dafederThanks - I want ahead and just used the old theme method of hiding the field labels for empty fields... but so we can put this to rest, here's the html from one of my test views where fields are showing. This is the html from two nodes, one has content in its fields, one doesn't except for the title.
Comment #7
merlinofchaos commentedSo here's the thing:
<div class="field-content"></div>That's markup provided by CCK that is making Views think the field is not empty. Which is what I thought in #1. I can't do anything about that.
Comment #8
dafederBut, the only place anywhere in drupal where "field-content" is produced is in views, in the default views-view-fields.tpl.php. If you disable CCK, the body field is still wrapped in the field-content div.
Comment #9
elandirayan commentedHai Defeder,
One tric to Hide the field. I tried lot with views and done one tricky work. What i done is in the row stryle template, i add the striptags and replaced. It is working fine.
Please find the sample in my row style template file:
foreach ($fields as $id => $field):if (!empty($field->separator)):print $field->separator;endif;$elan = strlen(strip_tags($field->content));if ($elan > 1):if ($field->label):print $field->label;print $field->content;endif;endif;endforeach;Comment #10
prabhakarsun commentedFor me, adding a filter of the field worked. i.e. if you are getting a blank imagefield [ex. product photo], add imagefield true filter. [ex. product photo - true].
Comment #11
Kasha Linka commentedAdding the filter suggested in #10 worked for me, too. Seems that simply setting up the field and row style settings to not display the field if it's empty weren't enough. The filter was also needed. Thanks very much for this thread.
Comment #12
AlanAtLarge commentedSubscribing
Comment #13
itserich commentedsubscribing
Comment #14
anrikun commentedShouldn't this be opened again because of #8?
I'm having the same issue.
So far, the only way to hide empty fields seems to be to check "Hide if empty" at field level, one by one(!)
Checking "Hide empty fields" as row level has absolutely no effect.
Comment #15
aspacepig commentedThanks Manoj! #10 worked like a charm. Drupal gets a lot more fun once one starts to get the hang of views.
Comment #16
iamjon commentedI'm marking this as closed.
I'm quite sure the mark up is coming from cck in the text formatter.