We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Yet another text-limit / excerpt plugin

Development and Programming

silenz's avatar
silenz
1,648 posts
18 years ago
silenz's avatar silenz

TruncHTML

This plugin basically does the same as the Character Limiter plugin but aims to do it in a “HTML-safe” way.

When counting the characters it ignores HTML-Tags. It does not truncate the text inside HTML-tags and it closes tags that are left open after truncating the text.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.

I’ve been reading these forums for a long time and have never come across this. It seems to be the subject of numerous threads - how come this one is so hard to find?

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
18 years ago
Ingmar Greil's avatar Ingmar Greil

TruncHTML is quite young, really. It was announced/released in this thread on Jul 3, I believe.

       
Bruce2005's avatar
Bruce2005
536 posts
18 years ago
Bruce2005's avatar Bruce2005

If this does what I hope it does, great!! I have a client who wants exxcerpts (word limit) on a menu of posts. He usually puts images first and so far have been unable to find a way to remove them.

Does this ignore/remove images?

Thanks…

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.

@Bruce2005: My Eexcerpt plugin removes images (see the link in my signature). But it remove ALL tags, so line breaks aren’t preserved. That may or may not help you out. I’d like to update it to preserve line breaks, but I’m a little swamped with actual work right now.

       
Bruce2005's avatar
Bruce2005
536 posts
18 years ago
Bruce2005's avatar Bruce2005

It sounds perfect as is 😊

Thank you, am trying it out later today, much needed addon..

       
silenz's avatar
silenz
1,648 posts
18 years ago
silenz's avatar silenz

I’ve just been informed it has been added to the Add-On Library 😊

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.

This is almost what I’m looking for! The main issue I’m having is that I can’t add an ellipsis (…) to the end of the truncated HTML - an ellipsis gets plopped in after the last closing tag, which is generally a paragraph tag, which means the ellipsis is always on the next line. And the link at the end always shows up on the next line then, too. It’s hard to account for those closing tags as they could almost be anything, I know.

I think it would be nice to have the ellipsis attached to the last characters of the excerpt, and then the “Read On” link could show on the next line. Is there a good way to approach that?

       
silenz's avatar
silenz
1,648 posts
18 years ago
silenz's avatar silenz
I think it would be nice to have the ellipsis attached to the last characters of the excerpt, and then the “Read On” link could show on the next line.

Actually I have been considering that, too. That possibility will be added sooner or later.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.

Sooner is good!

Just kidding. Thanks for adding another plugin to the text excerpt pile.

       
silenz's avatar
silenz
1,648 posts
18 years ago
silenz's avatar silenz

If you download the latest version from the link in the first post of this thread, there’s a new parameter named inline=”“.

What you put in there will be added after the truncated text and before any auto-closed tags.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.

That’s pretty much what I was after. I’ll download and take it for a test drive. Thank you!

UPDATE Installed and working fine. Great plugin.

       
sm9's avatar
sm9
352 posts
18 years ago
sm9's avatar sm9
If you download the latest version from the link in the first post of this thread, there’s a new parameter named inline=”“. What you put in there will be added after the truncated text and before any auto-closed tags.

I’ve just downloaded the latest version and the inline parameter is a good addition, thanks.

My only gripe is that the plugin automatically inserts a single space before the inline text. Is there any chance you can adjust this so that the inline parameter text sits tight to the text of the entry? Then users could insert a space into the inline parameter if they wanted it? Or could have it tight? So giving people either option.

Here’s an example, I want to add ‘…’ after the end of the posts that are truncated, yet it looks a bit silly when my text reads:

This is my text …

I’d prefer if it were possible to sit tight, like this:

This is my text…

This would be especially true for when using the ‘exact=yes’ parameter as it would make cut-off words look neater.

What do you think? That’s my only comment for making this plugin perfect for me! It doesn’t look noticable when you look at it above, but on a website with larger text it does make a difference I think.

Thanks for your hard work,

Ste

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.
Here’s an example, I want to add ‘…’ after the end of the posts that are truncated, yet it looks a bit silly when my text reads:
This is my text …
I’d prefer if it were possible to sit tight, like this:
This is my text…

sm9 - If you want to change that yourself without waiting for an official new release, I believe all you need to do is change line 93 from

$truncate .= " " . $inline;

to

$truncate .= $inline;

I could be wrong, but that is where the space is being added.

       
sm9's avatar
sm9
352 posts
18 years ago
sm9's avatar sm9
Here’s an example, I want to add ‘…’ after the end of the posts that are truncated, yet it looks a bit silly when my text reads:
This is my text …
I’d prefer if it were possible to sit tight, like this:
This is my text…
sm9 - If you want to change that yourself without waiting for an official new release, I believe all you need to do is change line 93 from
$truncate .= " " . $inline;
to
$truncate .= $inline;
I could be wrong, but that is where the space is being added.

Ahh, thanks mdesign, I’ll give that a go! 😊

Ste

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.