Limit product title virtuemart 2.0.10
I want to limit the title of the product.
I'm very happy to help you
thanks
[attachment cleanup by admin]
Try this:
<?php
function limitWords($text, $maxwords = 5) {
$text = strip_tags( $text );
$words = split( ' ', $text );
$text='';
foreach ($words as $i=>$word){
if ($i < $maxwords) {
$text.=' '.$word;
} else {
$text.='...';
break;
}
}
return $text;
}
/**/
echo limitWords($product->product_name);
there is already a vmart function
the 40 is the amount of characters
the ... is what apears when its cutoff
<?php echo shopFunctionsF::limitStringByWord ($product->product_name, 40, '...') ?>
http://forum.virtuemart.net/index.php?topic=97744.0
http://forum.virtuemart.net/index.php?topic=90935.0