- 5 Votes | avg rating 4.80
- Favorited 6 times
- No Reviews
Feedback
For support related questions and bug-reports please use the form over here.- best managed web hosting
- Large Selection Cell Phone Accessories
- web design services
Pingbacks
1. My Standard ExpressionEngine Addons | Jack McDade
on 2009-02-18 08:12:39:
[...]will. It changed my life. Kind of. ThruncHTML Type: Plugin Price: Free[...]
TruncHTML
| Version | Released | Type | License |
|---|---|---|---|
| 1.3.1 | 2009-02-25 | Plugins | Freeware (?) |
The difference is, that TruncHTML is HTML-aware, so you can use it to shorten HTML-formatted text and keep the markup without being afraid of breaking it.
Unlike the standard limiter-plugins it does not count characters that belong to HTML-tags and does not cut-off in the middle of tags.
| Example: Limit to 16 characters. |
Take a look <a href="ref.html"><img src="arrow.gif" /></a> at this page.
|
| TruncHTML: |
Take a look <a href="ref.html"><img src="arrow.gif" /></a> at
|
| Standard char_limit: |
Take a look <a href="ref.html"><img…
|
Furthermore it tries its best to close all tags that remain open after the text has been limited.
So if you limit the following text to 80 chars...
<p class="quote"><b>Never let your sense of morals get in the way of doing what's right.<br />
<em>Isaac Asimov</em></b></p>
the result will be ...
<p class="quote"><b>Never let your sense of morals get in the way of doing what's right.<br />
<em>Isaac</em></b></p>
instead of ...
<p class="quote"><b>Never let your sense of morals get in the way of doing what's
... which would probably screw the rest of the page.
[...]there wouldn’t be anything wrong with a separate plugin that is content aware. Silenz’s TruncHTML does a fabulous job with that, in fact I use it myself, and I don’t particularly see a reason for a first party solution to be made.[...]
Derek Jones, EllisLab
Comments
2009-05-15 03:32
Just a note to other users. If you want a link at the end to the full post and you put the link in the ending=”” parameter it will appear below the text. However if you add that link to the inline=”” parameter it will flow directly with the rest of the text.
2009-05-09 09:24
This plugin is great. Thank you so much. The only one that doesnt break the HTML compared to a host of others that I have tried!
2009-03-03 05:41
Hi there,
Is it possible for you to add a dont_strip_tags feature to TruncHTML? I’m working on a client’s site, and we’re applying TruncHTML to a field that has paragraph tags in it. Since it closes the tag automatically, the “...” we want at the end of the excerpt shows up on a new line.
If you need some $ for this, I can re-bill it.
Please advise direct to bas AT expdesign DOTT net if you can.
Thanks,
Ben
2009-02-12 20:33
And of course I couldn’t have remembered everything in the first post, now could I? ![]()
You’ll need to append this to the “With this” code segment in my previous post, to take into account cases where there aren’t any HTML tags in the parsed text:
// No HTML tags to put the inline string inside
if ($truncated == 0)
{
$truncate .= $inline;
}
2009-02-12 20:02
Hi Oliver,
I just spent an hour adding features to TruncHTML that I needed, only to discover that you had added most of them in the versions between 1.1.2 (which is on the EE site) and what’s here. ![]()
However, there is one thing I added to my customized version that is still missing from yours: placing the “inline” string outside of any inline tags, but inside of any block-level tags.
Currently, in your Asimov quote example, the “inline” string would be placed inside the still-open <em> and <b> tags. I’ve modified the plugin to place the “inline” string outside of all tags until the first closing block-level tag (p, div, or blockquote).
Here is the parts I modified for you to look at; if you want to include it in the next version, feel free to modify it as you see fit - I’m aware it’s a bit crude in its implementation. ![]()
Replace this:
if (!empty($inline)) {
if (substr($inline,0,1)=="_") {
$inline = " ".ltrim($inline,"_");
}
$truncate .= $inline;
}
foreach ($open_tags as $tag) {
$truncate .= '</' . $tag . '>';
}
With this:
// counter to track if the truncation string has been added to the output yet
$truncated = 0;
foreach ($open_tags as $tag)
{
if ((!empty($inline)) AND ($truncated == 0) AND ($tag == "p" OR $tag == "div" OR $tag == "blockquote"))
{
if (substr($inline,0,1)=="_")
{
$inline = " ".ltrim($inline,"_");
}
$truncate .= $inline;
$truncated = 1;
}
$truncate .= '</' . $tag . '>';
}
2009-02-12 09:32

If you recently downloaded it from this site and actually installed it, it’s 1.3
2009-02-11 18:24
I downloaded 1.3, but it appears to be 1.2.2?
2009-01-23 11:56

@Jonathan:
The new release (Version 1.3) has a threshold-parameter that works like the “if_exceeds” in Word_limit_plus.
2009-01-14 13:44
Thanks for this excellent plugin. My only gripe so far is that it doesn’t have the buffer that Word Limit Plus has built in…
In Word Limit Plus one has parameters for if_exceeds and stop_after. Thus, if the value of stop_after is less than the value of if_exceeds, it creates a buffer whereby one can ensure that there is enough text left over to be worth reading!

@