Categories > TinyButStrong general >

Minor modification for max= parameter

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Cristian R.
Date: 2003-10-09
Time: 19:23

Minor modification for max= parameter

Hi, just a little quick hack for the max= parameter of Merge-Fields.

As is for TBS 1.81, the max= parameter just cuts the field being printed to 'max' characters, where ever the field exceeds it. This often doesn't look nice, as words are just plain truncated.

A nicer alternative is to replace the line 677 of tbs_class.php (v1.81) wich reads :

$tbs_CurrVal = substr($tbs_CurrVal,0,$max-1).'...' ;

to this :

$tbs_CurrVal = preg_replace('/\s\S*$/','...',substr($tbs_CurrVal,0,$max-3));

This minor modification prevents words from being truncated, when the field exceeds the max= value. The result is far more better, to my modest opinion.

Hope you like the tip. Credits for this are not mine, I just stole that one from Class SDConvertText, as found at phpclasses.org

Greetz from Argentina, home of Maradona, Tando & Dulce de Leche!
By: Skrol29
Date: 2003-10-13
Time: 10:55

Re: Minor modification for max= parameter

That's a very intersting tip.

I gonna have a deeper look to undertand how it works and eventually add it in the next version.