Author Topic: Short description length limit  (Read 10867 times)

ibarreto

  • Beginner
  • *
  • Posts: 11
Short description length limit
« 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


seyi

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 391
    • AwoDev
Re: Short description length limit
« Reply #1 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
Seyi A
--------------------
Promotion enhancement for Virtuemart:
   - AwoCoupon FREE - http://www.awocoupon.com/starter
   - AwoCoupon Pro - http://awodev.com/products/joomla/awocoupon
   - AwoRewards - http://awodev.com/products/joomla/aworewards
   - AwoAffiliate - http://awodev.com/products/joomla/awoaffiliate

ibarreto

  • Beginner
  • *
  • Posts: 11
Re: Short description length limit
« Reply #2 on: December 25, 2010, 12:57:20 pm »
thank you seyi, I will go in that direction.


PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10270
  • VirtueMart Version: 3+
Re: Short description length limit
« Reply #3 on: December 26, 2010, 01:58:26 am »
you can go into myphpadmin and change the character amount #
I do NOT do development work for hire.

WDCT

  • Beginner
  • *
  • Posts: 7
    • Website Design Cape Town
Re: Short description length limit
« Reply #4 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, '...') ?>

lipes

  • Sr. Member
  • ****
  • Posts: 720
Re: Short description length limit
« Reply #5 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
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

dobv

  • Beginner
  • *
  • Posts: 1
Re: Short description length limit
« Reply #6 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);  ?>

Genius WebDesign

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 173
    • Genius WebDesign
Re: Short description length limit
« Reply #7 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
}

    };
}());


});