How to cut off text after a certain amount of characters

baron_jon

Avatar: baron_jon

2012-02-16 10:18

How to cut off text after a certain amount of characters of product's name in products list? And how to add "..." insted of cut text? Something like wordwrap function.

» Quick.Cart v3.x

baron_jon

Avatar: baron_jon

2012-02-17 09:17

Open core/products.php and insert the line below into List products function. This is the only solution I found. Certainly you can change the name's lenght.


$aData
['sName'] = (strlen($aData['sName']) > 50) ? substr($aData['sName'],0,50).'...' $aData['sName'];

baronjon123@gmail.com

treewood (OpenSolution)

Avatar: treewood

2012-02-17 10:29

better solution is change
$aData['sName'] = checkLengthOfTxt( $aData['sName'] );

in libraries/Trash.php there is on top of file:
define( 'MAX_STR_LEN', 80 );

change to length You want

beholder

Avatar: beholder

2012-02-17 23:17

No, Treewood, I think he wanted long names but not in list, there they should be shortened like baron_jon said. Very nice.

http://cicmanec.sk/easyplugins/

treewood (OpenSolution)

Avatar: treewood

2012-02-18 08:02

Then:

$aData['sName'] = strlen( $aData['sName'] ) > 80 ? checkLengthOfTxt( $aData['sName'] ) : $aData['sName'];

substr is not good function for this because it cuts text and dont care it is half or 1/10 of word ...

baron_jon

Avatar: baron_jon

2012-02-18 15:23

I wanted exactly what I wrote in the second post. To cut all characters after certain amount of symbols and insert "..." at the end. In product list only.

Back to top
about us | contact