ccaspell Posted February 8, 2007 Share Posted February 8, 2007 I am using a template built by some one else and the left hand column has the function that displays the categories hard coded in. Unfortunately the code only allows for a menu two deep and I require a further level. At the moment the menu items one deep correctly indent with a little right arrow, but when the next level is reached the indentation is the same, making reading confusing. You can see the work-in-progress site at www.caspell.biz/catalog. Click on Vending Ingredients, then Auto Hot Drinks and you will see what I mean. The code for the LH column is below. Any help greatly received. Chris <?php /* $Id: column_left.php,v 1.15 2003/07/01 14:34:54 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <table border="0" cellspacing="0" cellpadding="0"> <tr><td width="225" height="31" bgcolor="#525152"> <?=tep_image(DIR_WS_IMAGES.'m18.gif','','','','class="ab"')?> <span class="tx1"><?=BOX_HEADING_CATEGORIES?></span></td></tr> <tr><td height="15" bgcolor="#F6F6F6"></td></tr> <tr><td bgcolor="#F6F6F6"> <table border="0" cellspacing="0" cellpadding="0" width="190" align="center"> <tr><td> <a href="/catalog/mgraphics.php"><img src="/catalog/images/machinegraphics.gif" border=0></a></td></tr> <tr><td><ul> <? function tep_show_category($counter) { global $tree, $categories_string, $cPath_array, $ii; if ($tree[$counter]['next_id']==false) $kk='class="el"'; else $kk=''; $ii++; if(!$tree[$counter]['level']){ $categories_string .= $categories_string ? '' : ''; $categories_string .= '<li '.$kk.'><a href='; if ($tree[$counter]['parent'] == 0) { $cPath_new = 'cPath=' . $counter; } else { $cPath_new = 'cPath=' . $tree[$counter]['path']; } $categories_string .= tep_href_link('index.php', $cPath_new) . '>'; // display categry name $categories_string .= $tree[$counter]['name']; //$categories_string .= '<img src="/catalog/images/machinerange.gif" border=0>'; $categories_string .= '</a></li>'; }else{ // SUBCATEGORY $categories_string .= ''; for($i=0;$i<$tree[$counter]['level'];$i++) $categories_string .= ''; $categories_string .= '<li '.$kk.'><a href='; if ($tree[$counter]['parent'] == 0) { $cPath_new = 'cPath=' . $counter; } else { $cPath_new = 'cPath=' . $tree[$counter]['path']; } $categories_string .= tep_href_link('index.php', $cPath_new) . '><img src="/catalog/images/m19.gif" border=0> '; // display category name $categories_string .= $tree[$counter]['name']; //$categories_string .= '<img src="/catalog/images/vending.gif" border=0>'; $categories_string .= '</a></li>'; } if ($tree[$counter]['next_id'] != false && $ii < 20) { tep_show_category($tree[$counter]['next_id']); } } define(TABLE_CATEGORIES, "categories"); define(TABLE_CATEGORIES_DESCRIPTION, "categories_description"); $categories_string = ''; $tree = array(); $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='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { $tree[$categories['categories_id']] = array('name' => $categories['categories_name'], 'parent' => $categories['parent_id'], 'level' => 0, 'path' => $categories['categories_id'], 'next_id' => false); if (isset($parent_id)) { $tree[$parent_id]['next_id'] = $categories['categories_id']; } $parent_id = $categories['categories_id']; if (!isset($first_element)) { $first_element = $categories['categories_id']; } } //------------------------ if ($cPath) { $new_path = ''; reset($cPath_array); while (list($key, $value) = each($cPath_array)) { unset($parent_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 = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); if (tep_db_num_rows($categories_query)) { $new_path .= $value; while ($row = tep_db_fetch_array($categories_query)) { $tree[$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($parent_id)) { $tree[$parent_id]['next_id'] = $row['categories_id']; } $parent_id = $row['categories_id']; if (!isset($first_id)) { $first_id = $row['categories_id']; } $last_id = $row['categories_id']; } $tree[$last_id]['next_id'] = $tree[$value]['next_id']; $tree[$value]['next_id'] = $first_id; $new_path .= '_'; } else { break; } } } $categories_string .= ''; tep_show_category($first_element); $categories_string .= ''; echo $categories_string; ?> </ul></td></tr> <tr><td height="14"></td></tr> </table> </td></tr> <tr><td width="225" height="57"> <table border="0" cellspacing="0" cellpadding="0" width="135" align="center"> <tr><td width="135"><span class="tx2"> </span></td></tr> <tr><td height="6"></td></tr> <tr><td align="center"> <? /* echo tep_draw_form('currencies', tep_href_link(basename($PHP_SELF), '', $request_type, false), 'get'); reset($currencies->currencies); $currencies_array = array(); while (list($key, $value) = each($currencies->currencies)) { $currencies_array[] = array('id' => $key, 'text' => $value['title']); } $hidden_get_variables = ''; reset($HTTP_GET_VARS); while (list($key, $value) = each($HTTP_GET_VARS)) { if ( ($key != 'currency') && ($key != tep_session_name()) && ($key != 'x') && ($key != 'y') ) { $hidden_get_variables .= tep_draw_hidden_field($key, $value); } } echo tep_draw_pull_down_menu('currency', $currencies_array, $currency, 'onChange="this.form.submit();" class="se"') . $hidden_get_variables . tep_hide_session_id(); echo '</form>'; */ ?> </td></tr> </table> </td></tr> <? include(DIR_WS_BOXES . 'best_sellers.php'); ?> </table> Link to comment Share on other sites More sharing options...
bkellum Posted February 8, 2007 Share Posted February 8, 2007 This is most likely controlled by a image (arrow). Look in your images folder for the graphic listed in the code above. You will most likely need to edit that image in Photoshop to get what you want for the deeper menu item. Bill Kellum Sounds Good Productions STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE Link to comment Share on other sites More sharing options...
ccaspell Posted February 8, 2007 Author Share Posted February 8, 2007 This is most likely controlled by a image (arrow). Look in your images folder for the graphic listed in the code above. You will most likely need to edit that image in Photoshop to get what you want for the deeper menu item. Hi Bill, Thanks for your suggestion, but I don't think this is the case for two reasons: (1) I added the graphic to the code myself (about half way down - the following code): $categories_string .= tep_href_link('index.php', $cPath_new) . '><img src="/catalog/images/m19.gif" border=0> '; This is in the sub-categories section, about line 52. The second reason is the following, if the indentation was decided by a graphic then where is the second graphic for the deeper menu item? There doesn't appear to be one; if there was then, as you say, I could amend the graphic to add some more white space to the left and thus increase the indent. I can only deduce that the code has been written to only have two categories rather than more and that is why I wondered if someone could look at the code and see how the function worked and then tell me which bit needs to be duplicated/modified to create a third class of indentation. Thanks anyway for your help. Chris Link to comment Share on other sites More sharing options...
ccaspell Posted February 9, 2007 Author Share Posted February 9, 2007 I am still having trouble with this one if any one ha sany ideas. Link to comment Share on other sites More sharing options...
Velveeta Posted February 9, 2007 Share Posted February 9, 2007 I am still having trouble with this one if any one ha sany ideas. You're missing the indentation code that's normally there, it's been blanked out: }else{ // SUBCATEGORY $categories_string .= ''; for($i=0;$i<$tree[$counter]['level'];$i++) $categories_string .= ''; // <----- This line should be something like ' '; $categories_string .= '<li '.$kk.'><a href='; Richard. Richard Lindsey Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.