VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Administration & Configuration VM 1.1 => Topic started by: ibarreto on December 19, 2010, 07:34:48 am

Title: Short description length limit
Post by: ibarreto on December 19, 2010, 07:34:48 am
Hello, is there a way to limit the number of characters in the short description of products? At least limit the short description that appears on the product list per category.

thank you

Title: Re: Short description length limit
Post by: seyi on December 19, 2010, 18:05:14 pm
You will probably have to do some custom coding for that
www/components/com_virtuemart/themes/[default]/templates/browse/[your_browse_template].php

You can limit the $product_s_desc variable with substr
Title: Re: Short description length limit
Post by: ibarreto on December 25, 2010, 12:57:20 pm
thank you seyi, I will go in that direction.

Title: Re: Short description length limit
Post by: PRO on December 26, 2010, 01:58:26 am
you can go into myphpadmin and change the character amount #
Title: Re: Short description length limit
Post by: WDCT on February 21, 2012, 15:08:03 pm
VM2

Edit components/com_virtuemart/views/category/tmpl/default.php

Find:

<?php echo shopFunctionsF::limitStringByWord($product->product_s_desc, 40, '...') ?>

Change to:

<?php echo shopFunctionsF::limitStringByWord($product->product_s_desc, 200, '...') ?>
Title: Re: Short description length limit
Post by: lipes on April 03, 2012, 19:51:14 pm
its possible to edit this in VM2 in PRODUCT DETAILS not in the categorie!?
I add this words to test in product ...  "g sgag hq 4tht whwc hwj r j g sgag hq 4tht whwc hwj r jg sgag hq 4tht whwc hwj r jg sgag hq 4tht whwc hwj r jg sgag hq 4tht whwc hwj r j g sgag hq 4tht whwc hwj r j g sgag hq 4tht whwc hwj r jg sgag hq 4tht whwc hwj r jg sgag hq 4tht whwc hwj r jg sgag hq 4tht whwc hwj r j"
but there is no end / limit!! and short description is very long now in VM2 :S

i try to call that code:
    <?php
    // Product Short Description
   if(!empty($product->product_s_desc)) { ?>
        <div class="product-short-description">
      <?php echo shopFunctionsF::limitStringByWord($product->product_s_desc, 20, '...') ?>
        </div>
    <?php } ?>

but doesnt work in product details
Title: Re: Short description length limit
Post by: dobv on June 19, 2012, 10:17:28 am
You will probably have to do some custom coding for that
www/components/com_virtuemart/themes/[default]/templates/browse/[your_browse_template].php

You can limit the $product_s_desc variable with substr

<?php echo $product_s_desc = substr("$product_s_desc", 0, 200);  ?>
Title: Re: Short description length limit
Post by: Genius WebDesign on September 30, 2015, 15:29:27 pm
I know this is an old EOL thread, but I thought I should share this little trick.

If you want to make in input check in admin form before saving a product this can pretty easily be done with pure JS applied to your admin template.

We want to extend the javascript function: Joomla.submitbutton
and here is how it´s done, an example where I check if long_desc   
is longer than 4999 chars (using MCE content editor):

Code: [Select]
jQuery(document).ready(function(){

Joomla.submitbutton = (function() {
    var cached_function = Joomla.submitbutton;

    return function(str) {



if(jQuery(".layout-product_edit #product_desc_parent iframe#product_desc_ifr").contents().find("body.mceContentBody").length) {   

var longdescrvar = jQuery(".layout-product_edit #product_desc_parent iframe#product_desc_ifr").contents().find("body.mceContentBody").html().length;   
if(longdescrvar > 4999){
alert("Long description must not be more than 4999 characters. There currently is: " + longdescrvar);
return false;
}
else {
        cached_function.apply(this, arguments); // use .apply() to call it
}
}
else {
        cached_function.apply(this, arguments); // use .apply() to call it
}

    };
}());


});