projects / org / ezproject2010 / smartshort
Find the Exponential Software extensions you want
UNIX name | Owner | Status |
---|---|---|
smartshort | Steven E. Bailey | stable |
Version | Compatible with |
---|---|
1.0 | 4.x |
The problem with the default shorten template operator is that it's a substring
of the input, so it will break wherever it will land... including in the middle
of a word. Another problem is that if the input is an xml block with tags those
could end in the middle of a html tag and mess up the layout of the rest of
the page. Or, with a long tag - which wouldn't be visible but would count in
the total for the sub string - would make the visible string too short.
Since practically all of our customers want minimal html tags in their line
views (see the strip_except template operator) - and want their line views
to all be shortened - it has always been problematic and up until now we've
only been able to allow self-closing tags or the content editors had to edit
the line view text block attribute carefully so that no html tags would be
stranded. That didn't always happen. Especially with user-generated content.
What smartshort will do is take the string and find the nearest end of
sentence punctuation and, if the length of the string (not including html tags)
at that point is less than the user-defined percentage of deviation, break
the text block there.
If the length of the string at that point is more than the percentage of
deviation, then the string will be shortened to the white space nearest the
length set in the template. if the length of the string at this point is
still bigger than the user-defined percentage of deviation, (which could happen
with a long run-on word and a short length) then it will break at the character
like the existing shorten.
The tags will be inserted but will not count toward the string length - since
they are hidden. While calculating the length of the string, the
non-self-closing html tags are kept in an array, and if there are still open
tags when the string is to be displayed, those tags will be closed. That list
of tags is user-defined.