Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Attaching a backport of the functionality introduced in D8. Patch to come.
Comment | File | Size | Author |
---|---|---|---|
#17 | smart_trim-revert_patch-2372857-17.patch | 15.6 KB | kallehauge |
#16 | smart_trim-revert_patch-2372857-16.patch | 15.99 KB | kallehauge |
#8 | smart_trim-n2372857-8.patch | 15.59 KB | DamienMcKenna |
Comments
Comment #1
markie CreditAttribution: markie commentedUploaded for your approval.. Please place the TruncateHTML.inc_.txt file into a directory named src and rename to .inc
Comment #2
DamienMcKennaDoes the license in http://www.pjgalbraith.com/wp-content/uploads/TruncateHTML.php.txt preclude it from being included directly?
Comment #3
markie CreditAttribution: markie commentedA better patch that includes the src file. (h/t. Damien)
Comment #4
DamienMcKennaComment #5
markie CreditAttribution: markie commentedUpdated TruncateHTML class to come to Drupal Coding Standards.
Comment #6
DamienMcKennaI suspect you should revert the hellip change, and add a default value for this new setting.
Comment #7
DamienMcKennaThis reverts some of the unrelated changes, changes back to using the original code, and adds a note to the README.txt about where the code came from.
Comment #8
DamienMcKennaIt'd help if I verified that the inc file wasn't missing anything.
Comment #9
markie CreditAttribution: markie commentedAdded a few coder details and applied to 7.x-1.x-dev build.
Comment #10
lolandese CreditAttribution: lolandese commentedA commit has not been made. See https://www.drupal.org/node/1555182/commits.
Patch does apply cleanly but some errors are reported.
Tested with https://www.drupal.org/project/demo_flickr node/1.
Smart trimmed with 50 characters results in the image being displayed (HTML) but none of the text. If the HTML would not have been counted, then some text should appear.
The same for 10 words.
Thanks.
Comment #11
markie CreditAttribution: markie commented@lolandese - can you hit me up on IRC (teampoop) so we can talk about what you are seeing please?
Comment #12
lolandese CreditAttribution: lolandese commentedHi Mark,
I am at work now. I prefer using the issue queue and could send you some screenshots tonight.
It should be easy to replicate with the sandbox demo of the Flickr module. After install, just upload the patched Smart Trim module archive at admin/modules/install. Also remove the
<!--break-->
tag at the end of node 1 and obviously apply Smart Trim on the display of the body in Teaser view with all the right settings.Hint:
It might be that Smart Trim kicks in before the text filter gets applied. That would explain a lot.
Thanks for looking into this.
Comment #13
lolandese CreditAttribution: lolandese commentedScreenshots as promised (the image title explains what ST settings are used), plus patched module to upload in the sandbox.
Comment #15
maximpodorov CreditAttribution: maximpodorov commentedPlease revert the commit. The used library is erroneous in processing non-English texts. See strlen() and other bad things. I have broken Russian characters after this commit.
Comment #16
kallehauge CreditAttribution: kallehauge commentedAs @Maximpodorov said; there is no support for non english text. I have reverted the patch since it's committed to the dev branch and would highly suggest some other way to do this :)
Comment #17
kallehauge CreditAttribution: kallehauge commentedSorry, I was a bit too quick when I created the patch. This is created from the root of the module instead of the previous one in #16 :)
Comment #19
markie CreditAttribution: markie commentedI have reverted the commit and will look into a solution that addresses multi-byte characters.
Comment #20
markie CreditAttribution: markie commented@maximpodorov
@kallehauge
Can you guys try checking out the 7.x-1.x-truncate branch and test it against some of your non standard characters. I have updated strlen() to mb_strlen(). Would love to know the specifics of "other bad things" if possible..
Thanks for your help on this!
markie
Comment #21
maximpodorov CreditAttribution: maximpodorov commentedWhere is the branch?
Comment #22
DamienMcKenna@markie: How about just using drupal_strlen?
Comment #23
markie CreditAttribution: markie commented@maximpodorov: you'll have to checkout via GIT. Since it's not using a standardized name the branch will not be built into a release. Use the following command:
If Damien's suggestion pans out I may just commit it back to the dev build though.
@DamienMcKenna: because I had no idea it existed? Since this was a third party class, I didn't even look. I'll give that a try. Also will have to look at using the Unicode class in D8.
Comment #24
DamienMcKenna@markie: If you do change the library, make sure you document it in the README.txt.
Comment #25
pawel_r CreditAttribution: pawel_r commentedIf somebody has need for not counting html tags, please use: https://www.drupal.org/project/field_html_trim