I have a Views block on the home page of my site (http://directionpersonaltraining.com/) that I am using to display a "Blog Post Preview". I am using the "Trim this field to a maximum length" feature in Views on the body of the post. In the Views preview all works well. When I look at it on the homepage the title and comment count are display but the body field is left blank. There is mark-up for it in the HTML but no text is output. I thought this might be a Views issue but when I switch the site to Bartik or Stark, the trimmed text from the body field is there leading me to believe it is an Omega issue.

I found a couple issues in the Views queue that may be related:
http://drupal.org/node/954238
http://drupal.org/node/1014486

Really looking forward to using this theme.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

2ndmile’s picture

I suppose I should add that I am using a sub-theme created from the starterkit in the Omega theme.

himerus’s picture

I'm definitely puzzled why this would happen because of Omega... there is no real manipulation of views directly BY the Omega base theme...

It will take some digging to test this one out and narrow it down a bit. Any additional debugging you can provide will help!! But I'll see what I can do.

2ndmile’s picture

himerus... let me know what I can do to help... I am willing to give you admin access on the site if that would help. I really want to try Omega since I have been using zen_ninesixty but it does not have a D7 version and Omega has a ton of cool features.

himerus’s picture

I'm really thinking this has to be something in views rendering.... I just down see how/where Omega could be doing ANYthing that would affect this data.

I will continue to look, but I think one of those issues you linked had the most relevant data, that the trimmed setting now was almost useless with the field output settings for fields in content types. I need to read a bit more to fully understand how this has changed the way views renders trimmed text.

Is your trimmed text in a views display with field values or as a node display??

himerus’s picture

Status: Active » Closed (cannot reproduce)
FileSize
110.06 KB

I'm marking this as "cannot reproduce".

The attached screenshot shows my own view of nodes with title (node) and body (field) fields, and I've set the body field to trim to a max length of 255 chars.

This is working as expected in my own installation with the starterkit.
Please make sure your views, ctools to the latest versions.

Again, my confusion on this issue is that there is nothing Omega does that modifies field content from views. The only custom views code in Omega is a slight modification to the pager and mini pager theme functions. nothing more.

2ndmile’s picture

Thanks for taking the time on this.

Try checking the "Strip HTML tags" checkbox. Without that checked everything shows as expected. But again.. this problem only happens when Omega is used.

To answer your questions, my views display is using field values. Views and cTools are latest versions.

himerus’s picture

I did have strip html both checked and not, and got at least some stuff back... the issue sure was seeming to be in the other views issues where html wasn't escaped, and then did something wonky in the source code...

I'm just not sure... especially why this would seemingly only happen in Omega.
I'm using views on a LOT of D7 projects right now, and haven't had this issue (even in one large project with dozens of views field displays with trimmed fields)

2ndmile’s picture

Truly strange... attached two screen shots. First shows results in bartik. Second results in omega subtheme. The only difference between the two is changing the theme.

himerus’s picture

Status: Closed (cannot reproduce) » Active

Marking this back as active....

Can you paste the export of your view for me to test with?

2ndmile’s picture

Again, I can give you admin access to this site if you think that would help.

/**
 * Implement hook_views_default_views().
 */
function foo_views_default_views() {
  /*
   * View 'blog_previews'
   */
  $view = new view;
  $view->name = 'blog_previews';
  $view->description = '';
  $view->tag = '';
  $view->base_table = 'node';
  $view->human_name = 'Blog Previews';
  $view->core = 7;
  $view->api_version = '3.0-alpha1';
  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

  /* Display: Defaults */
  $handler = $view->new_display('default', 'Defaults', 'default');
  $handler->display->display_options['access']['type'] = 'none';
  $handler->display->display_options['cache']['type'] = 'none';
  $handler->display->display_options['query']['type'] = 'views_query';
  $handler->display->display_options['exposed_form']['type'] = 'basic';
  $handler->display->display_options['pager']['type'] = 'some';
  $handler->display->display_options['pager']['options']['items_per_page'] = '3';
  $handler->display->display_options['pager']['options']['offset'] = '0';
  $handler->display->display_options['style_plugin'] = 'default';
  $handler->display->display_options['row_plugin'] = 'fields';
  /* Field: Node: Title */
  $handler->display->display_options['fields']['title']['id'] = 'title';
  $handler->display->display_options['fields']['title']['table'] = 'node';
  $handler->display->display_options['fields']['title']['field'] = 'title';
  $handler->display->display_options['fields']['title']['label'] = '';
  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
  $handler->display->display_options['fields']['title']['element_label_colon'] = 1;
  $handler->display->display_options['fields']['title']['element_default_classes'] = 1;
  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
  /* Field: Fields: body */
  $handler->display->display_options['fields']['entity_id']['id'] = 'entity_id';
  $handler->display->display_options['fields']['entity_id']['table'] = 'field_data_body';
  $handler->display->display_options['fields']['entity_id']['field'] = 'entity_id';
  $handler->display->display_options['fields']['entity_id']['label'] = '';
  $handler->display->display_options['fields']['entity_id']['alter']['alter_text'] = 0;
  $handler->display->display_options['fields']['entity_id']['alter']['make_link'] = 0;
  $handler->display->display_options['fields']['entity_id']['alter']['absolute'] = 0;
  $handler->display->display_options['fields']['entity_id']['alter']['trim'] = 1;
  $handler->display->display_options['fields']['entity_id']['alter']['nl2br'] = 0;
  $handler->display->display_options['fields']['entity_id']['alter']['max_length'] = '500';
  $handler->display->display_options['fields']['entity_id']['alter']['word_boundary'] = 1;
  $handler->display->display_options['fields']['entity_id']['alter']['ellipsis'] = 1;
  $handler->display->display_options['fields']['entity_id']['alter']['strip_tags'] = 1;
  $handler->display->display_options['fields']['entity_id']['alter']['preserve_tags'] = '<a>';
  $handler->display->display_options['fields']['entity_id']['alter']['html'] = 1;
  $handler->display->display_options['fields']['entity_id']['element_label_colon'] = 0;
  $handler->display->display_options['fields']['entity_id']['element_wrapper_type'] = 'span';
  $handler->display->display_options['fields']['entity_id']['element_default_classes'] = 1;
  $handler->display->display_options['fields']['entity_id']['hide_empty'] = 0;
  $handler->display->display_options['fields']['entity_id']['empty_zero'] = 0;
  $handler->display->display_options['fields']['entity_id']['settings'] = array(
    'trim_length' => 600,
  );
  /* Field: Node: Comment count */
  $handler->display->display_options['fields']['comment_count']['id'] = 'comment_count';
  $handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics';
  $handler->display->display_options['fields']['comment_count']['field'] = 'comment_count';
  $handler->display->display_options['fields']['comment_count']['alter']['alter_text'] = 0;
  $handler->display->display_options['fields']['comment_count']['alter']['make_link'] = 0;
  $handler->display->display_options['fields']['comment_count']['alter']['absolute'] = 0;
  $handler->display->display_options['fields']['comment_count']['alter']['trim'] = 0;
  $handler->display->display_options['fields']['comment_count']['alter']['word_boundary'] = 1;
  $handler->display->display_options['fields']['comment_count']['alter']['ellipsis'] = 1;
  $handler->display->display_options['fields']['comment_count']['alter']['strip_tags'] = 0;
  $handler->display->display_options['fields']['comment_count']['alter']['html'] = 0;
  $handler->display->display_options['fields']['comment_count']['element_label_colon'] = 1;
  $handler->display->display_options['fields']['comment_count']['element_default_classes'] = 1;
  $handler->display->display_options['fields']['comment_count']['hide_empty'] = 0;
  $handler->display->display_options['fields']['comment_count']['empty_zero'] = 0;
  $handler->display->display_options['fields']['comment_count']['format_plural'] = 0;
  /* Sort criterion: Node: Post date */
  $handler->display->display_options['sorts']['created']['id'] = 'created';
  $handler->display->display_options['sorts']['created']['table'] = 'node';
  $handler->display->display_options['sorts']['created']['field'] = 'created';
  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
  /* Filter: Node: Type */
  $handler->display->display_options['filters']['type']['id'] = 'type';
  $handler->display->display_options['filters']['type']['table'] = 'node';
  $handler->display->display_options['filters']['type']['field'] = 'type';
  $handler->display->display_options['filters']['type']['value'] = array(
    'blog_post' => 'blog_post',
  );

  /* Display: Blog Preview */
  $handler = $view->new_display('block', 'Blog Preview', 'block_1');
  $translatables['blog_previews'] = array(
    t('Defaults'),
    t('more'),
    t('Apply'),
    t('Reset'),
    t('Sort By'),
    t('Asc'),
    t('Desc'),
    t('Comment count'),
    t('.'),
    t(','),
    t('Blog Preview'),
  );
  $views[$view->name] = $view;

  return $views;
}
abbasmousavi’s picture

I have the same problem but there is a more strange point. On my dev server there is no problem but when I copy the code and database on my production server trimmed fields are empty. there is the html tag for the field but it is empry. I have tested trim text .. and also field formatter and the problem only exist with Omega.
I am confused.

abbasmousavi’s picture

Version: 7.x-2.0-alpha8 » 7.x-2.0-alpha10

selecting "summary or trimmed" formatter solved the problem if you don't select "strip HTML tags"!

2ndmile’s picture

I noticed that as well during my troubleshooting. I am using this as a Blog Post Preview that fits into the template is a very specific way so i would like to strip Only local images are allowed. and the like. I suppose I could "display:none".

On the other hand, it is probably good to squash this bug.

miche’s picture

Title: Views - No output by "Trim this field to a maximum length" - Only in Omega » Views - No output by "Trim this field to a maximum length"
Status: Active » Closed (works as designed)

Hi Everyone,

I have encountered the same issue.

My setup:
standard install profile
no additional themes added
Views, CTools, Devel as the only contrib modules

What didn't work:
1. Body field, trim field to a maximum length, 100 characters, trim only on a word boundary, add an ellipsis, formatter = Default.

What DID work:
1. Body field, trim field to a maximum length, 200 characters, trim only on a word boundary, add an ellipsis, formatter = Default.
2. Body field, formatter = Summary or Trimmed, 200 characters

Because Omega was not downloaded into this site, I am marking this issue as closed. I am still looking to see if there already is an issue open in Views or elsewhere. Clearly there is an issue with the trimming before it is passed to the theme layer.

cooldeeponline’s picture

Title: Views - No output by "Trim this field to a maximum length" » Solved!

I tried these settings and it worked:

Maximum length: 8 (it cant be any value as per your requirement)

1. Uncheck "Trim only on a word boundary"
2. Check the following options:
i) Add an ellipsis
ii) Field can contain HTML
iii) Strip HTML tags

N.B.If you would like to strip the userame:
i) Check Output this field as a link
ii) In the Link path: set it as [name]

escoles’s picture

Title: Solved! » Views - No output by "Trim this field to a maximum length"

Changing title back as "solved!" is not informational in the context of an issues listing. (i.e., good to be able to see what problems the solutions are for without having to open the issue.)

osopolar’s picture

[deleted wrong post]