Forums / Templates, Stylesheets, Page Layout / How to set a character limit for product title when in product listing mode?

How to set a character limit for product title when in product listing mode?

Started by gabriel2506 on 12 Feb 2013, 11:30 PM · Views: 3,927

Results 1 to 8 of 8
12 Feb 2013, 11:30 PM
#1
gabriel2506 avatar

gabriel2506

New Zenner

Join Date:
Feb 2013
Posts:
2
Plugin Contributions:
0

How to set a character limit for product title when in product listing mode?

I want to set a character limit when my product titles are showing in product listing pages.

I do want to keep the long titles when you are looking a product page, I just want to set a limit of character showing when customer browse for products as the title goes down on 2-3 lines and it doesn't look nice.

Is there any presets to do that? Or do you have to change code to do it? If so, what do I have to change and can you give me a detail instruction on how to do it.

Thanks you

13 Feb 2013, 1:55 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How to set a character limit for product title when in product listing mode?

admin > config > product listing > Display Product Description > set length

Zen-Venom Get Bitten

13 Feb 2013, 12:43 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,120
Plugin Contributions:
56

Re: How to set a character limit for product title when in product listing mode?

gabriel2506:

I want to set a character limit when my product titles are showing in product listing pages.

I do want to keep the long titles when you are looking a product page, I just want to set a limit of character showing when customer browse for products as the title goes down on 2-3 lines and it doesn't look nice.

Is there any presets to do that? Or do you have to change code to do it? If so, what do I have to change and can you give me a detail instruction on how to do it.

Thanks you
Like kobra indicated, you can set the limits for the product *description *in your admin but not the product title. To limit the number of characters in a product's name on your product listing pages, you'll need to:

  1. Copy /includes/modules/product_listing.php to /includes/modules/YOUR_TEMPLATE/product_listing.php.

  2. Edit that file; for the v1.5.1 version, the code to change is on line 97. Change

        $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';

to

        $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . zen_trunc_string($listing->fields['products_name'], 50) . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';

If 50 is not the right number of characters, just change the 50 to whatever works for you!

14 Feb 2013, 2:25 AM
#4
gabriel2506 avatar

gabriel2506

New Zenner

Join Date:
Feb 2013
Posts:
2
Plugin Contributions:
0

Re: How to set a character limit for product title when in product listing mode?

Thank you so much! You are amazing!

6 Jan 2015, 6:56 AM
#5
w2e avatar

w2e

Zen Follower

Join Date:
Oct 2007
Posts:
103
Plugin Contributions:
0

Re: How to set a character limit for product title when in product listing mode?

this does not help me. my title is still cut off? i changed '50' to '150' but my title length is still cut off at 64.
i change table orders_products field products_name to varchar(128) (from varchar64) restart mysqld and still no good? i do not see produt_name in the table products?

6 Jan 2015, 8:29 AM
#6
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: How to set a character limit for product title when in product listing mode?

w2e:

this does not help me. my title is still cut off? i changed '50' to '150' but my title length is still cut off at 64.
i change table orders_products field products_name to varchar(128) (from varchar64) restart mysqld and still no good? i do not see produt_name in the table products?

You can find products_name in the products_description table

6 Jan 2015, 9:30 AM
#7
w2e avatar

w2e

Zen Follower

Join Date:
Oct 2007
Posts:
103
Plugin Contributions:
0

Re: How to set a character limit for product title when in product listing mode?

changed products_name in the products_description table to varchar 128.
restart mysql.
re-upload, and import. it finally works.

apparently, with varchar 64, imported title was saved as 64 characters. so i have to import again.

also when the title is cut off, import results in warning/error too.

thanks

6 Jan 2015, 2:39 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How to set a character limit for product title when in product listing mode?

Be aware that if you changed the length of the products_name in the table products, you also have to do the same in the table orders_products or the name will be cut off on orders ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!