[Typo3] crop whole words - SOLVED
Toni Milovan
tmilovan at efpu.hr
Fri Nov 11 20:02:27 CET 2005
This is a repost from typo3-dev list:
Hi to all that helped.
I have finally managed to solve this problem:
The problem generally is that tt_news does not use standard crop
function from class.tslib_content.php, but crop function from
class.t3lib_cs.php instead.
And while this function has utf-8 handling built in, it does not have a
possibility to accept third parameter for croping of whole words.
Even more, it seems that tt_news does not forwards charset parameter to
this function. That leaves us with function that does not recognize
charset (which is not always the problem, but it is with utf-8), and
which is not able to cut out whole words.
The first problem (whole word cropping) is solveable by adding something
like this:
if ($len > 0) {
if (strlen($string{$i})) {
$string = substr($string, 0,
$i);
$pos = strrpos($string, " ");
if($pos === false) {
return substr($string,
0, $i);
} else {
return substr($string,
0, $pos).$crop;
}
}
} else {
....
}
... at the correct place somewhere below the line 1414 at
class.t3lib_cs.php
This works fine for me.
The second problem will have to resolve someone from tt_news team by
adding correct function call when calling crop function. I have forced
crop function to always act as if we have utf-8, but that of course is
not a good way to do it.
However, if you urgently need a solution you can do it like I did.
Wolfgang and Christian suggested that crop function should be called
from class.tslib_content.php, and maybe that is the right solution
because it seems that function call in tt_news is actually designed for
this function but I don't know how well will this function handle utf-8.
So, that's it. If I did get something wrong please correct me before I
fill bugreport.
Thanks,
Toni
On Sub, 2005-11-05 at 20:09 +0100, Toni Milovan wrote:
> Hi,
>
> I'm trying to force crop function to preserve whole words but no matter
> how do I put it it breaks the words. Eg.:
>
> plugin.tt_news.displayList.subheader_stdWrap.crop = 80 | ... | 0
>
> or
>
> plugin.tt_news.displayList.subheader_stdWrap.crop = 80 | ... | 1
>
> ... the resulting crop is always the same.
>
> Btw, im using the utf-8 charset and maybe that is the reason for
> misbehaviour?
>
> What do you think?
>
> Regards,
>
> Toni
>
>
> _______________________________________________
> Typo3-english mailing list
> Typo3-english at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
--
Toni Milovan <tmilovan at efpu.hr>
More information about the TYPO3-english
mailing list