Cyber-Drugs Posted July 25, 2004 Posted July 25, 2004 Go here http://67.15.2.6/~dogbert/Online/index.php?cPath=21_35_34 you can see my categories are brocken up, I need to fix this. What I had in mind was maybe putting the abreviations on the categories list on the left and the full name on the right. Could someone tell me how to do this? Which files to edit, and such? Thanks :) Cyber-Drugs B)
♥yesudo Posted July 25, 2004 Posted July 25, 2004 length of cat name is def the prob. where on right ? Your online success is Paramount.
Cyber-Drugs Posted July 25, 2004 Author Posted July 25, 2004 What do you mean by "where on right ?" ?? :huh: Cyber-Drugs B)
♥yesudo Posted July 25, 2004 Posted July 25, 2004 categories list on the left and the full name on the right. you tell me... Your online success is Paramount.
Cyber-Drugs Posted July 25, 2004 Author Posted July 25, 2004 Sorry about that. I want the short names on the left in the category box, but on the right, which is where you see the product description, I dont want an abreviation, I want the proper full name in the title. So only an abreviation in the categories bit, and no where else. Thanks :) Cyber-Drugs B)
Cyber-Drugs Posted July 25, 2004 Author Posted July 25, 2004 No one got any ideas then? (didnt edit my last post as I dont have acces rights yet) If someone has any ideas please let me know. Thanks :) Cyber-Drugs B)
burt Posted July 25, 2004 Posted July 25, 2004 Couple of options: 1/ Don't bother having subcategories in the main categories box. I do this on a few sites and it works well. or 2/ Look at the substr function of PHP. http://uk.php.net and apply to the sub category names. Search this forum for substr and eventually you'll find a post by me showing how to do something like this.
Cyber-Drugs Posted July 25, 2004 Author Posted July 25, 2004 I don't mind going with option one, is there an option in the admin area to do this? Or how do I go about doing it? Thanks :) Cyber-Drugs B)
burt Posted July 25, 2004 Posted July 25, 2004 I rolled my own, which wouldn't suit your needs as it looks like this: There is (I'm certain) a few contributions that will do what you need. Have a search through the contributions section. If you go with option 2, try this, unsure if it will work exactly as intended, but it'll give you a start: /includes/boxes/categories.php Find this: $categories_string .= $tree[$counter]['name']; Replace it with this: if ($tree[$counter]['parent'] != 0) { $categories_string .= substr($tree[$counter]['name'], 0, 5); } else { $categories_string .= $tree[$counter]['name']; }
burt Posted July 25, 2004 Posted July 25, 2004 The number 5 in this line: $categories_string .= substr($tree[$counter]['name'], 0, 5); determines the length of your subcategory name. In this code, the length would be 5 characters. Amend to suit your needs.
Cyber-Drugs Posted July 25, 2004 Author Posted July 25, 2004 I would really love to use that code Burt, but I am afraid I am using a category box contribution made by 241. I will post the code for it, so maybe you could tell me what I need to change? <?php /* $Id: categories.php,v 1.23 2002/11/12 14:09:30 dgw_ Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2002 osCommerce Released under the GNU General Public License */ function tep_show_category($counter) { global $foo, $categories_string, $id, $aa; for ($a=0; $a<$foo[$counter]['level']; $a++) { if ($a == $foo[$counter]['level']-1) { $categories_string .= "<font color='#ff0000'> </font>"; } else { $categories_string .= "<font color='#ff0000'> </font>"; } } if ($foo[$counter]['level'] == 0) { if ($aa == 1) { $categories_string .= tep_image(DIR_WS_IMAGES . '../templates/CyberLaneOnline/images/hr01.gif', '3', '137', '') . '<br>'; } else {$aa=1;} } $categories_string .= '<nobr><a nowrap href="'; if ($foo[$counter]['parent'] == 0) { $cPath_new = 'cPath=' . $counter; } else { $cPath_new = 'cPath=' . $foo[$counter]['path']; } $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new); $categories_string .= '">' . tep_image(DIR_WS_IMAGES . 'e02.gif', '') . ' ';; if ( ($id) && (in_array($counter, $id)) ) { $categories_string .= "<b><font color='#ff0000'>"; } // display category name $categories_string .= $foo[$counter]['name']; if ( ($id) && (in_array($counter, $id)) ) { $categories_string .= '</font></b>'; } // if (tep_has_category_subcategories($counter)) { // $categories_string .= '->'; // } $categories_string .= '</nobr></a>'; // if (SHOW_COUNTS == 'true') { // $products_in_category = tep_count_products_in_category($counter); // if ($products_in_category > 0) { // $categories_string .= ' (' . $products_in_category . ')'; // } } $categories_string .= '<br>'; if ($foo[$counter]['next_id']) { tep_show_category($foo[$counter]['next_id']); } } ?> <!-- categories //--> <tr> <td> <?php $aa = 0; echo $categories_string; $categories_string = ''; // add links to products with no category $product_query = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = 0 and p.products_id = pd.products_id and pd.language_id ='" . (int)$languages_id . "' order by pd.products_name " ); while ($no_category = tep_db_fetch_array($product_query)) { $no_cat_product_id = $no_category['products_id']; $no_cat_products_name = $no_category['products_name']; $myref = "<a href=" . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $no_cat_product_id) . '>' . $no_cat_products_name . '</a><br><br>'; $categories_string .= $myref; } // end links to products with no category $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { $foo[$categories['categories_id']] = array( 'name' => $categories['categories_name'], 'parent' => $categories['parent_id'], 'level' => 0, 'path' => $categories['categories_id'], 'next_id' => false ); if (isset($prev_id)) { $foo[$prev_id]['next_id'] = $categories['categories_id']; } $prev_id = $categories['categories_id']; if (!isset($first_element)) { $first_element = $categories['categories_id']; } } //------------------------ if ($cPath) { $new_path = ''; $id = split('_', $cPath); reset($id); while (list($key, $value) = each($id)) { unset($prev_id); unset($first_id); $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $value . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name"); $category_check = tep_db_num_rows($categories_query); if ($category_check > 0) { $new_path .= $value; while ($row = tep_db_fetch_array($categories_query)) { $foo[$row['categories_id']] = array( 'name' => $row['categories_name'], 'parent' => $row['parent_id'], 'level' => $key+1, 'path' => $new_path . '_' . $row['categories_id'], 'next_id' => false ); if (isset($prev_id)) { $foo[$prev_id]['next_id'] = $row['categories_id']; } $prev_id = $row['categories_id']; if (!isset($first_id)) { $first_id = $row['categories_id']; } $last_id = $row['categories_id']; } $foo[$last_id]['next_id'] = $foo[$value]['next_id']; $foo[$value]['next_id'] = $first_id; $new_path .= '_'; } else { break; } } } tep_show_category($first_element); $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => $categories_string ); new InfoBox($info_box_contents); ?> </td> </tr> <!-- categories_eof //--> Thanks :) Cyber-Drugs B)
burt Posted July 25, 2004 Posted July 25, 2004 This is the problem when people use non-standard Oscommerce :( Speak with 241 who may be able to help you further.
burt Posted July 25, 2004 Posted July 25, 2004 It *might* work if you change this: $categories_string .= $foo[$counter]['name']; to this: if ($foo[$counter]['level'] != "0") { ?$categories_string .= substr($foo[$counter]['name'], 0, 5); } else { ?$categories_string .= $foo[$counter]['name']; } If not, 241 is your man.
Cyber-Drugs Posted July 25, 2004 Author Posted July 25, 2004 Works a charm thanks, but was wondering if it was possible to change it slightly... Instead of shorting the cagegory names to the first 5 letters, how about abreviating them by taking the first letter of each word and putting a "." between each letter EXAMPLE: Legend Of Blue Eyes => L.O.B.E. <- Over 12 Chars long Magic Ruler => Magic Ruler <- Under 12 Chars long Hard to do? Thanks again :) Cyber-Drugs B)
burt Posted July 25, 2004 Posted July 25, 2004 Yes, anything is possible. What you are asking for is something that would take some thinking about (I think). Expect to get your wallet out if you need it badly, unless someone kinder than me will do it for nothing...
Cyber-Drugs Posted July 25, 2004 Author Posted July 25, 2004 It's just simple text manipulation, I think I will just go look it up myself thnx :P Thanks for all the help thus far though :) Cyber-Drugs B)
burt Posted July 25, 2004 Posted July 25, 2004 It's just simple text manipulation, I think I will just go look it up myself thnx :P Cool. When you get it working, will you post it back to the thread as it could be useful for others in the future. Thanks :)
Cyber-Drugs Posted July 26, 2004 Author Posted July 26, 2004 Sure, here is the code. You need to add this function somewhere at the top of categories.php function truncate($string, $max = 12, $seperator = '.') { if (strlen($string) <= $max) return $string; $tmpA = explode(" ", $string); foreach ($tmpA as $key => $value) { $tmpA[$key] = substr($value, 0, 1); } $outstring = implode($seperator, $tmpA).$seperator; return $outstring; } and replace this: $categories_string .= $foo[$counter]['name']; with this: $categories_string .= truncate($foo[$counter]['name']); Cyber-Drugs B)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.