Plain text fields with all english lorem ipsum text gets "ignored" instead of trimmed when set to "Trim to a maximum length", with or without word boundaries checked.

Assigning to myself so I can dig deeper when I find the time.

Comments

phizes’s picture

I'm not sure this will help anyone.

When I set the max length of trim to be greater than a 133 characters I get the field returned with the number of characters greater than 133 of what I set it to, so if I set it to 150 characters I get 17 characters as the trimmed string. So I'm adding a 133 to what I need for now as a work around.

I haven't tried this with breaking on word boundaries on as my test data was just the long strings from the devel module and I haven't looked further yet.

ephemerol’s picture

Further to the above, checking 'Remove all HTML tags' also resolves the issue (tested on Fields: body). Note that preserving HTML tags such as <p> causes no problems.

phizes’s picture

After looking into it further, it seems that HTML tags are being passed to the function that does the trimming of the field on rendering of the page, which I think is creating the 133 character offset. The function that is used to trim the text uses drupal_strlen, if I set the starting point to the second character it breaks the HTML tags, they can then be seen in place of where the field data should be rendered.
There is a TODO in the source to replace most of the function with cleanstring of ctools, I don't think that is related to this problem though.

I haven't found where the "extra" (or more correctly, just in the incorrect place, I think) HTML is being added, and I'm out of time for investigating for now, takes me ages because I haven't looked at views source before. I also have no clue how things are done with views so I think this is as far as I can try help on this one.

qwermans’s picture

same error on my site
it works for live preview, then i save. it doesnt work on page.
(i use omega theme)

merlinofchaos’s picture

Status: Active » Fixed

The extra HTML is probably coming from field.tpl.php -- you need to use the -dev version and make sure the box to use field.tpl.php is unchecked. That'll fix this problem.

Status: Fixed » Closed (fixed)

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