News:

Support the VirtueMart project and become a member

Main Menu

Limit product title

Started by vanqui, April 23, 2013, 11:42:19 AM

Previous topic - Next topic

vanqui

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]

andrew.overlord

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);


PRO

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