I have a basic view of the latest posts to the site, using the core "Articles" content type.

Displaying fields title, date posted, body. Setting body to "summary or trimmed" does not display anything. Reverting to default text, restores it. Any thoughts?

Comments

neoglez’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

I can not reproduce this one. Would try with the latest dev?
Try this:

$view = new view;
$view->name = 'post';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Post';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Post';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
  ),
);
$handler->display->display_options['style_options']['override'] = 1;
$handler->display->display_options['style_options']['sticky'] = 0;
$handler->display->display_options['style_options']['empty_table'] = 0;
/* Field: Content: 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']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$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: Content: Body */
$handler->display->display_options['fields']['body']['id'] = 'body';
$handler->display->display_options['fields']['body']['table'] = 'field_data_body';
$handler->display->display_options['fields']['body']['field'] = 'body';
$handler->display->display_options['fields']['body']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['body']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['body']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['body']['alter']['external'] = 0;
$handler->display->display_options['fields']['body']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['body']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['body']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['body']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['body']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['body']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['body']['alter']['trim'] = 0;
$handler->display->display_options['fields']['body']['alter']['html'] = 0;
$handler->display->display_options['fields']['body']['element_label_colon'] = 1;
$handler->display->display_options['fields']['body']['element_default_classes'] = 1;
$handler->display->display_options['fields']['body']['hide_empty'] = 0;
$handler->display->display_options['fields']['body']['empty_zero'] = 0;
$handler->display->display_options['fields']['body']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['body']['type'] = 'text_summary_or_trimmed';
$handler->display->display_options['fields']['body']['settings'] = array(
  'trim_length' => '600',
);
$handler->display->display_options['fields']['body']['field_api_classes'] = 0;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'post';
pixelsweatshop’s picture

i have imported the view and it only displays the node title, not the summary/trimmed body. (on a side note, I am running the latest dev of ctools (Because Commerce requires it). Would that affect it?

kccmcck’s picture

I can confirm this issue.

I have a body field in D7 which also allows the user to define a separate summary (set to Full HTML). If the summary field is left empty, however, it should print a trimmed output from the full body field, but instead returns nothing. The trimmed body is empty.

If I leave the summary field empty BUT set the body input format to Plain text and remove HTML tags, the trimmed version prints correctly. I need to use the Full HTML filter and leave the WYSIWYG editor intact.

I am using Views to output a Display Suite display mode.

rhazor’s picture

Confirmed. Trimmed body shows up only if its trimmed with 600 and up. If I want body to be trimmed for ~200 or 100 nothing shows up. Using dev versions of all tools.

UPDATE: Not views bug. Just tried to create a simple article and publish to front page and got Body teaser empty (in fields its set to be trimmed to 200). The interesting part is that when content goes without break lines its not showing up neither with simple article teaser in front page or with Views field: Body (with trimmed). But if I add a break line (just simple space between text rows) then both, simple article teaser and Views field body shows the first headline.

UPDATE: Never mind. Had problems in Text formats (Filtered HTML). I just set the default values and settings and it all works now. Maybe everyone else is having same problem, try changing your Text formats settings.

dawehner’s picture

@rhazor
So this bug is fixed? If yes feel free to change the status of the issue.

neoglez’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Yes: format settings.

p.brouwers’s picture

Status: Closed (works as designed) » Active

Sorry to reopen, but the same issue still exists with filter 'full HTML'.
With that filter no trimmed text is displayed when set to trim to 200 characters.

The only difference with 'filtered HTML' is of course the option to filter HTML tags in format settings. If I enable that for 'full HTML' then the trimmed text shows up.

Anyone an idea why this is happening?

beauz’s picture

Subscribing I'm also getting this problem.

I'm using CKeditor which wraps the body text in

tags. Seems removing the p tags allows it to be trimmed. However I need to keep the

tags.

rt_davies’s picture

subscribe. experiencing same. cannot find any workaround.

rt_davies’s picture

Never mind. Had problems in Text formats (Filtered HTML). I just set the default values and settings and it all works now. Maybe everyone else is having same problem, try changing your Text formats settings.

@rhazor: could you give more details about what you changed to fix the problem. I can't find anything wrong with my Text formats. Thanks!

kgeeraerts’s picture

Same problem here (also for custom fields with a summary setting).
I am using CKEditor and removing the p-tags indeed solves the problem but this isn't really an option (try to explain that to a customer).
Full HTML format looks OK so I can't imagine this works as intended if it's such a hassle to find a solution.

UPDATE: This worked for me --> CKEditor settings > Cleanup and output > enable "Use custom formatting options", then disable "break line after opener tag" !
Trimming now works as it should and the text shows up.

dawehner’s picture

But as you know, this IS NOT an issue of views. Views justs uses the formatter provided by core.

beauz’s picture

Thanks @KennyGeeraerts your solution worked for me!

kerios83’s picture

I can't see BODY when I set up a view and add a body field...

dawehner’s picture

@kerios83
Please try to be more specific and explain what see means: You can't add the field or you don't see something when you look at the output of the field?
Additional take care about the things mentioned above ... views will not fixed the formatter provided by core.

kerios83’s picture

I have set up a view and after upgrade drupal to 7.8 i can't see body field. I had added Content: Body to every view so I can see content. Now I can't see content in (all my) views. I think it's clear explanation.

I have noticed that [body] == Content: Body is now [field_body] == Content: Body in Replacement patterns. Maybe you guys have and idea what happened.

dawehner’s picture

@kerios83
This sounds like a somehow new issue, so please try to create a new clean bug report which enough informations.
If you want us to help you, please read http://drupal.org/node/571990 before creating an issue.

pixelsweatshop’s picture

I can confirm #11 worked for me as well. Knowing this, is everyone using ckeditor? If so, maybe I will post an issue there.

dawehner’s picture

Status: Active » Fixed

Okay it seems to be somehow specific problem. Nicoz can't reproduce it and it's probably not a bug of views.

pixelsweatshop’s picture

I can reproduce it and I can confirm that enabling "Use custom formatting options" and disabling "break line after opener tag" in ckeditor settings does fix the issue. My conclusion is that this is a ckeditor issue and not views.

Status: Fixed » Closed (fixed)

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

ryan.gibson’s picture

I'd like to add that I had this problem as well. #11 fixed my issue, however, I still ran into the issue when I was pasting text into the body field. When I typed something manually into the field it worked. Additionally, when I pasted text into the plain text field and then switched to full html it also worked. That's odd.

CLC’s picture

Hi I am having a similar issue with CK editor - text that is present when I edit it and also prview is not being shown when viewing. It seems that lines in

tags are not being displayed. Is this related?

Many thanks in advance.

Lucas Meyer’s picture

I ran into this issue today. I managed to fix it, but this was the first Google result, so I figure I'd post an update:

When you tell Drupal to use the 'trimmed' filter, or the 'summary or trimmed' filter, it will trim whatever you give it; if the content includes HTML tags, it will trim the HTML tags. My sample content had a very long opening tag (from pasting into CKEditor), so the trim was actually returning the first part of the tag, not the first part of the content within the tag.

If you're running into this problem with a WYSIWYG editor, try disabling the editor and viewing the raw HTML source, then check to see if your opening tag is longer than your trim length. If it is, that's your problem. Try changing the opening <p style="..."> tag to <p>, and see if that fixes the issue.

Personally, I fixed all my issues by installing the Smart Trim (http://drupal.org/project/smart_trim) module, selecting the filter, and telling it to strip the HTML. After that, I had no further issues, even with copy-pasted CKEditor styles.

itapplication’s picture

Status: Closed (fixed) » Active

Hi,
I am having a similar issue with Drupal 7 - view 7.x-3.6. I can't find any workaround with it.

Christian DeLoach’s picture

Same problem here. Using CKEditor with Full HTML format. #11 worked for me as well but you have to edit the existing nodes for the change to take effect.

neilos78’s picture

I had this exact issue trying to display trimmed/summary in a view. If found that in the Configure field: Content: Body options, under Rewrite results, if i selected the Strip HTML tags , the summary displayed in the view output fine.

Sigvard’s picture

The suggestion to use the smart trim module solved the problem for me.

mennonot’s picture

Issue summary: View changes

Thanks, neilos78, that suggestion worked for me. I just gave up on "Trimmed" and "Summary or Trimmed" under Formatter for Content: Body. Intead I used the the Trim this field to a maximum length, trim on word boundary, add ellipsis and strip html tags check boxes under Rewrite Results. It worked great.

alancoughlin’s picture

The teaser text was not showing for just one of the articles listed in my view. I found that when I switched to plain text, there was a bunch of Microsoft formatting in the code. This usually happens when copying and pasting from MS Word without using the "Paste from Word" button. I copied the text and cleaned it by pasting it into a text editor, deleted all of the garbage, and pasted it back in.