Hide if empty in Views3 standard row plugin hides the labels as well. And I noticed a bug because of this. So this patch fixes it.

Comments

Scott Reynolds’s picture

I believe this issue is related: #773238: Reduce white space and line breaks in HTML output?. Essentially, the field output was comprised of new lines and therefore not empty. I suspect that if you did a

empty(trim($field_output));

it would make the hide if empty work again.

Scott Reynolds’s picture

StatusFileSize
new793 bytes

Doing that makes it work with user profile pictures who return something different when the row is empty. Which is why Earl did it that way to begin with Im sure...

gausarts’s picture

Status: Needs review » Reviewed & tested by the community

You solved the problem with my vud listings. No matter what I did in the .tpl files, the empty row still holds the markup.

Thank you.

gausarts’s picture

Status: Reviewed & tested by the community » Needs work

Ah, darn. The pagers won't go away, it still counts the empty rows. Sorry to get excited too soon :(

Scott Reynolds’s picture

Status: Needs work » Needs review

Ah, darn. The pagers won't go away, it still counts the empty rows.

this patch doesn't deal with empty rows. It deals with empty columns in the row. And if fixes a bug where Semantic Views doesn't work the same way as the normal Fields row plugin works.

What you are trying to achieve doesn't sound like Views can handle it. Its not a Row style plugin issue its a Views issue.

Anonymous’s picture

Scott: I'm happy to commit this patch, but I am a bit confused. Can you clarify before I commit? Why don't Views 2 or 3 also trim the output in template_preprocess_views_view_fields() ?

Scott Reynolds’s picture

because of the linked issue above, Semantic Views adds new line to the output.

Perhaps its better to fix the new line, so prevent adding new line to the output from the style plugin->get_field() when the field is empty.

Anonymous’s picture

Scott: I still don't understand. White space collapses in HTML unless it's wrapped in <pre> or if it's in an element that is styled with CSS white-space: pre or pre-wrap.

If a field is empty and the row option skip_blank or the field option hide_empty is enabled, the field and its label aren't added to the template variables, just like Views 2. If these options aren't enabled, the empty field value may swim in a sea of white space, but that won't matter.

Are you using PRE? Is this a workaround for a buggy browser that doesn't support standard HTML?

I need to see an example of this bug.

Scott Reynolds’s picture

White space collapses in HTML

Sure, but

$string = "\n";
if (!empty($string)) {
  print 'not empty';
}
else {
  print 'pass everything is ok';
}

prints not empty. Which is a simplified version of

     $field_output = $view->style_plugin->get_field($view->row_index, $id);
     $empty = $field_output !== 0 && empty($field_output);

This means that hide when empty doesn't work when the $view->style_plugin->get_field() returns "\n"

Anonymous’s picture

Ok Scott. I'm sorry for being so "unreachable" on this issue. Thanks for your patience in helping me understand it.

The template issue is a red-herring then. Semantic Views does not add any lines to the output. The preprocess function we're patching is for the template with the excess white space. The field output is being rendered by the field handler.

I want to verify that this happens in Views without Semantic Views plugins enabled. If it does, this needs to be patched in Views as well. Can you share the View that has "\n" in the output? You said it was related to the user picture field?

Scott Reynolds’s picture

I want to verify that this happens in Views without Semantic Views plugins enabled.

It doesn't thats how I decided to open an issue here.

Interestly, I see what you are getting at. views_plugin_style::get_fields(). Strange that this is returning non-empty stuff

$this->rendered_fields[$count][$id] = $this->view->field[$id]->theme($row);

The field handler in question is just views_handler_field.

 $data['location_user']['city'] = array(
    'title' => t('City'),
    'help' => t('The city this user is located within.'),
    'field' => array(
      'handler' => 'views_handler_field'
    ),
  );

I might spend some more time on it but honestly, this patch fixed it for us. Its no longer a bug. And Views standard style plugins worked just fine and behaved properly. It has to be a bug here, just not sure why.

henrijs.seso’s picture

subsc.

Scyther’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)