Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Long category names


quetzlcoatl

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...