Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Long category names


quetzlcoatl

Recommended Posts

Posted

Some of my category names are kinda long and either overhang the edge of the box or are squished into two rows (I'm using the graphical infobox header contribution with a background image).

 

Is there a way to limit the length of the category names as displayed in the category box, without changing anything in mysql? I need the full category name to display with the product listing.

 

Any help would be greatly appreciated!

Posted

You can try to expand the box width in ...

 

"catalog/includes/application_top.php"

 

On line 58 you will probably see something like...

 

// customization for the design layout
 define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125)

 

Just change your box width to a higher number and see if that works for you.

Posted

In includes/boxes/categories.php (around line 35), changing

    $categories_string .= $tree[$counter]['name'];

to

    $categories_string .= substr($tree[$counter]['name'], 0, 20 - 2*$tree[$counter]['level']);

will limit all category names to 20 spaces (including blanks preceding the category name). Adjust 20 as needed (e.g. if you can fit 40, change 20 to 40).

 

Hth,

Matt

Posted

Could you help with one more thing?

 

I would like to set the category names to 20 characters. If a category name is longer then 20, then shorten it and add "..." to the end of the cat name. I wrote this, but it's adding "..." to all cat names, even those that are four or five characters long:

 

if ($cat_name = $cat_length) {
     $categories_string .= substr($tree[$counter]['name'], 0, 20 - 2*$tree[$counter]['level']). "...";
   }
else {
     $categories_string .= $tree[$counter]['name'];
   }

 

I added a line under $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'; in categories.php that says:

 

$cat_length=20;

 

 

Thanks for your help!

Posted

AH-HA fixed.... if anyone else wants to know, here is the code that will limit cat names to 22 characters, if the name exceeds 22, then a "..." is placed after the shortened name!! Pretty cool. Thanks iiinetworks for helping with this!

 

Put this below $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';

 

$cat_length=22;

 

Then look for

 

$categories_string .= $tree[$counter]['name'];

 

And replace with

 

if (strlen($tree[$counter]['name'])>$cat_length) {
     $categories_string .= substr($tree[$counter]['name'], 0, $cat_length - 3). "...";
   }
else {
     $categories_string .= $tree[$counter]['name'];
   }

 

The "..." is good, that way if a cat name is cut short, it won't look confusing to the customer.

  • 1 month later...
Posted

Do you know how to fix the product title limit. I seem to have the same problem you had however it's in product name.

 

Thanks

 

Paris

Posted

It's the product Title...

 

Lets say i sell computers well it's not the catagorie name or the description of the product but rather the title of the product.

 

Thank you

 

Paris

Posted

If you want to limit the length of the product names everywhere on your site, you will have to edit in phpmyadmin and set the field length to a smaller number.

Posted

I was told that on one of my earlier post however i'm not sure what steps to take for this.

 

Isn't that the database area?

Posted

You should either have a direct link to phpmyadmin in your hosting control panel, or a database management link with a phpmyadmin link there. Just select the database you are using, click on the table name, products_description. The field you need to edit is products_name, click "change" beside it and set a new number there.

 

Another way, if you wanted to limit the length on just the product listing, would be to modify the php code similar to what I did for the category names. That would be in either catalog/includes/modules/product_listing.php or catalog/index.php

Posted

I got it to work ;-)

 

Thank you for your help everyone, finally got it working..

 

 

Thanks

 

Paris

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...