Guest Posted March 14, 2006 Posted March 14, 2006 Check this out... Whilst I only have three references to drop down or search boxes in my header bar, for some reason the categories drop down bar is occurring twice, I'm scratching my head over why it is doing this and am assuming there is a reference in the code refering to a file I haven't come across yet. Here's the code for the first html table in my header.php. <table border="0" width="98%" valign="middle" cellspacing="0" cellpadding="0"><tr class="header"> <td width="92%" valign="left"> <?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'logoth.gif', 'www.trailheadcycles.co.uk') . '</a>'; ?> </td> <td width="1" valign="left"> <table border="0" align="right"><tr><td width="23"> <?php include(DIR_WS_BOXES . 'categories_header.php'); ?> </td></tr></table> </td> <td width="1" valign="right"> <table border="0" align="right"><tr><td width="23"> <?php include(DIR_WS_BOXES . 'manufacturers_header.php'); ?> </td></tr></table> </td> <td width="1" valign="right"> <table border="0" align="right"><tr><td width="23"> <?php include(DIR_WS_BOXES . 'search2.php'); ?> </td></tr></table> </td> </tr> </table> And the offending double occurrence can be seen here...www.trailheadcycles.co.uk/catalog. Is it a question of having to give it a good kick? Good fun this...lol. Thanks again!
kgt Posted March 14, 2006 Posted March 14, 2006 This is your HTML source: <td width="1" valign="right"> <table border="0" align="right"><tr><td width="23"> <!-- manufacturers //--> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="1" class="infoBox"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="3" class="infoBoxContents"> <tr> <td><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="1"></td> </tr> <tr> <td align="left" class="TextBox"><form action="http://www.trailheadcycles.co.uk/catalog/index.php?osCsid=b761d0949ce67444095780a6da82c72a" method="get"><input type="hidden" name="osCsid" value="b761d0949ce67444095780a6da82c72a"><select name="cPath" onchange="this.form.submit();"><option value="" SELECTED>CATEGORIES</option><option value="1">ACCESSORIES</option><option value="1_17"> CDROM Drives</option><option value="1_4"> Graphics Cards</option><option value="1_8"> Keyboards</option><option value="1_16"> Memory</option><option value="1_9"> Mice</option><option value="1_6"> Monitors</option><option value="1_5"> Printers</option><option value="1_7"> Speakers</option><option value="2">BIKES</option><option value="2_19"> Action</option><option value="2_18"> Simulation</option><option value="2_20"> Strategy</option><option value="3">BRAKE SYSTEMS</option><option value="3_10"> Action</option><option value="3_13"> Cartoons</option><option value="3_12"> Comedy</option><option value="3_15"> Drama</option><option value="3_11"> Science Fiction</option><option value="3_14"> Thriller</option><option value="21">CLOTHING</option><option value="22">CONTROLS</option><option value="23">ELECTRONICS</option><option value="24">HYDRATION</option><option value="26">PROTECTION</option><option value="27">SUSPENSION</option><option value="28">TRANSMISSION</option><option value="29">WHEELS</option></select></form></td> </tr> <tr> <td class="TextBox"><form name="manufacturers" action="http://www.trailheadcycles.co.uk/catalog/index.php" method="get"><select name="manufacturers_id" onChange="this.form.submit();" size="1" style="width: 100%"><option value="" SELECTED>MANUFACTURER</option><option value="6">Canon</option><option value="4">Fox</option><option value="8">GT Interactive</option><option value="9">Hewlett Packard</option><option value="5">Logitech</option><option value="1">Matrox</option><option value="2">Microsoft</option><option value="7">Sierra</option><option value="3">Warner</option></select><input type="hidden" name="osCsid" value="b761d0949ce67444095780a6da82c72a"></form></td> </tr> <tr> <td><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="1"></td> </tr> </table> </td> </tr> </table> </td> </tr> <!-- manufacturers_eof //--> </td></tr></table> </td> It's in the same block as the manufacturers drop down. Look in manufacturers_header.php. Contributions Discount Coupon Codes Donations
Guest Posted March 14, 2006 Posted March 14, 2006 Well, I never thought to look at the source code. Don't understand what's going on though. So what you are saying is that even though the html on the header.php is okay, when it's loaded and the html for the live page is produced from the includes/boxes files for the drop down lists in the header bar, there is something in categories_header.php and manufacturers_header.php that means that the categories box get's generated twice? I would have thought that beings as the categories drop down menu is in there first, there is something missing to tell it to end? To be honest, I'm taking bits out on an experimental basis until it works as these drop down bars aren't intrusive, or in this case taking bits out until they don't work. Here's the code for categories_header.php: <!-- categories_header //--> <tr> <td> <?php function tep_get_paths($categories_array = '', $parent_id = '0', $indent = '', $path='') { global $languages_id; if (!is_array($categories_array)) $categories_array = array(); $categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' 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)) { if ($parent_id=='0'){ $categories_array[] = array('id' => $categories['categories_id'], 'text' => $indent . $categories['categories_name']); } else{ $categories_array[] = array('id' => $path . $parent_id . '_' .$categories['categories_id'], 'text' => $indent . $categories['categories_name']); } if ($categories['categories_id'] != $parent_id) { $this_path=$path; if ($parent_id != '0') $this_path = $path . $parent_id . '_'; $categories_array = tep_get_paths($categories_array, $categories['categories_id'], $indent . ' ', $this_path); } } return $categories_array; } $info_box_contents = array(); $info_box_contents[] = array('form' => '<form action="' . tep_href_link(FILENAME_DEFAULT) . '" method="get">' . tep_hide_session_id(), 'align' => 'left', 'text' => tep_draw_pull_down_menu('cPath', tep_get_paths(array(array('id' => '', 'text' => CATEGORIES))), $cPath, 'onchange="this.form.submit();"') ); new infoBox($info_box_contents); ?> </td> </tr> <!-- categories_header_eof //--> And for manufacturers_header.php: <?php $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); if ($number_of_rows = tep_db_num_rows($manufacturers_query)) { ?> <!-- manufacturers_header //--> <tr> <td> <?php if ($number_of_rows <= MAX_DISPLAY_MANUFACTURERS_IN_A_LIST) { // Display a list $manufacturers_list = ''; while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { $manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']); if (isset($HTTP_GET_VARS['manufacturers_id']) && ($HTTP_GET_VARS['manufacturers_id'] == $manufacturers['manufacturers_id'])) $manufacturers_name = '<b>' . $manufacturers_name .'</b>'; $manufacturers_list .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id']) . '">' . $manufacturers_name . '</a><br>'; } $manufacturers_list = substr($manufacturers_list, 0, -4); $info_box_contents = array(); $info_box_contents[] = array('text' => $manufacturers_list); } else { // Display a drop-down $manufacturers_array = array(); if (MAX_MANUFACTURERS_LIST < 2) { $manufacturers_array[] = array('id' => '', 'text' => MANUFACTURER); } while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { $manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']); $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'], 'text' => $manufacturers_name); } $info_box_contents[] = array('form' => tep_draw_form('manufacturers', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get'), 'text' => tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, (isset($HTTP_GET_VARS['manufacturers_id']) ? $HTTP_GET_VARS['manufacturers_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 100%"') . tep_hide_session_id()); } new infoBox($info_box_contents); ?> </td> </tr> <!-- manufacturers_header_eof //--> <?php } ?> I'm trying to see what would cause the categories box to generate twice, but can't. If I can get this fixed, I can post it up as a contribution as well as fix my site...lol.
kgt Posted March 14, 2006 Posted March 14, 2006 The reason: In categories_header.php, you create an array called $info_box_contents and create a new info box out of that array. $info_box_contents = array(); //this line initializes the array $info_box_contents[] = array('form' => '<form action="' . tep_href_link(FILENAME_DEFAULT) . '" method="get">' . tep_hide_session_id(), 'align' => 'left', 'text' => tep_draw_pull_down_menu('cPath', tep_get_paths(array(array('id' => '', 'text' => CATEGORIES))), $cPath, 'onchange="this.form.submit();"') ); //these lines append to the array new infoBox($info_box_contents); //this line creates a new box out of the array In manufacturers_header.php, you only append to the (already existing) array $info_box_contents and create a new info box. Since $info_box_contents is not re-initialized to an empty array, it already has the Categories dropdown information in it. else { // Display a drop-down $manufacturers_array = array(); if (MAX_MANUFACTURERS_LIST < 2) { $manufacturers_array[] = array('id' => '', 'text' => MANUFACTURER); } while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { $manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']); $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'], 'text' => $manufacturers_name); } $info_box_contents[] = array('form' => tep_draw_form('manufacturers', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get'), 'text' => tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, (isset($HTTP_GET_VARS['manufacturers_id']) ? $HTTP_GET_VARS['manufacturers_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 100%"') . tep_hide_session_id()); } new infoBox($info_box_contents); Add this line above the $info_box_contents[] line: $info_box_contents = array(); So the whole manufacturers_header.php should be: <?php $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); if ($number_of_rows = tep_db_num_rows($manufacturers_query)) { ?> <!-- manufacturers_header //--> <tr> <td> <?php if ($number_of_rows <= MAX_DISPLAY_MANUFACTURERS_IN_A_LIST) { // Display a list $manufacturers_list = ''; while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { $manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']); if (isset($HTTP_GET_VARS['manufacturers_id']) && ($HTTP_GET_VARS['manufacturers_id'] == $manufacturers['manufacturers_id'])) $manufacturers_name = '<b>' . $manufacturers_name .'</b>'; $manufacturers_list .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id']) . '">' . $manufacturers_name . '</a><br>'; } $manufacturers_list = substr($manufacturers_list, 0, -4); $info_box_contents = array(); $info_box_contents[] = array('text' => $manufacturers_list); } else { // Display a drop-down $manufacturers_array = array(); if (MAX_MANUFACTURERS_LIST < 2) { $manufacturers_array[] = array('id' => '', 'text' => MANUFACTURER); } while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { $manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']); $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'], 'text' => $manufacturers_name); } $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('manufacturers', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get'), 'text' => tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, (isset($HTTP_GET_VARS['manufacturers_id']) ? $HTTP_GET_VARS['manufacturers_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 100%"') . tep_hide_session_id()); } new infoBox($info_box_contents); ?> </td> </tr> <!-- manufacturers_header_eof //--> <?php } ?> Contributions Discount Coupon Codes Donations
Guest Posted March 14, 2006 Posted March 14, 2006 Yep spot on on ktg, you're an absolute star. I could see what you meant and now I can see why! All sorted, many, many thanks. I've just realised I've not eaten for nine hours so will post up the contrib as soon as I've had my dinner. Crystal clear! If you need any front end stuff doing, give me a shout. :thumbsup:
Recommended Posts
Archived
This topic is now archived and is closed to further replies.