Trimming a text-area field's length to "120" resulted in an actual display of 19 words. Changing the value to "220" resulted in an actual trim of 34 words. I've only had this problem since updating to 6.x-2.7.

I have "Add an ellipse" and "Trim only on word boundary" checked.

The ONLY pattern I could think of is that Views is reading each non-alpha-numeric character (";" or "?" or "") as its "HTML" code version. For example, any space in the field is being read as " " and for some reason each character in that code is being counted as a word (so 6 "words" for " ").

To test, I added 6 to the count whenever I encountered a non-alpha-numeric character in the trimmed text, and it came out to the original value I entered for the trim length in Views (Trim = 120, Result = 19 [real words] + [16 occurrences of spaces and/or non-alpha-numeric characters] * 6 = about 120).

Anyone have any idea why the Trim feature is spitting out arbitrarily trimmed results?

It sounds utterly crazy, I know. There must be a better explanation...

Comments

amaisano’s picture

Title: "Trim this field to a maximum length" does not trim correct amount of words! » "Trim this field to a maximum length" does not trim correct amount of words
amaisano’s picture

Ran a test on the follow field content:

"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"

And set the "Trim to..." value in Views to 15. The result:

1 2 3 4 5 6 7...

It's about half of what I wanted. What is going on? Is it counting each space as a word?

merlinofchaos’s picture

Priority: Critical » Normal
Status: Active » Closed (won't fix)

If checked, this field be trimmed to a maximum length in characters.

Don't know where you got 'words' from in that, but this feature does not do word counting, it does character counting.

Also, "critical" is reserved for crash bugs.

amaisano’s picture

Priority: Normal » Minor
Status: Closed (won't fix) » Closed (fixed)

And the winner of the Failure of the Week award goes to yours truly. Apologies to the Views team; there aren't any good excuses for missing that and the poor etiquette in these posts.