Guest Posted March 16, 2006 Posted March 16, 2006 Hiya, My Webpage I've managed to make up an addition which I've placed in my header which consists of a drop down categories bar, drop down manufacturers bar and the Simple_Search_Box_v2.1. The drop down bars select either a category or manufacturer listed and takes you through to the relevant products, the simple search bar is a rendering of the previous contrib (nice one!) linked into the advanced search functions. The problem is that I'm no php coder, I can get the jist of whats happening, but not 100% I thought everything was sorted after some nice advice in general support and was going to post it up as a contrib, but today I found a bug. If you see my homepage the "search group" is located underneath the header bar, in header.php. It all seems to work fine, but when I moved the group from above the bar after fixing the box height issues, to underneath and then uploaded header.php to check (effectively having two instances of the "search group"), I got an error message saying: Fatal error: Cannot redeclare tep_get_paths() (previously declared in /home/trailhea/public_html/catalog/includes/boxes/categories_header.php:7) in /home/trailhea/public_html/catalog/includes/boxes/categories_header.php on line 7 Which tells me there's something missing from categories_header.php. Could someone who know's what they are doing have a read through and locate my mistake? I got it to work on it's own, but I'm worried that there's a problem effecting my site with it and I don't want to post it up until it's right! Here's what I've done.... Added to includes/header.php <td width="1" align="right"><table><td width="23" align="right" valign="middle"> <?php include(DIR_WS_BOXES . 'categories_header.php'); ?> </td></table> </td> <td width="1" align="right"> <table><td width="23" align="right" valign="middle"> <?php include(DIR_WS_BOXES . 'manufacturers_header.php'); ?> </td></table> </td> <td width="1" align="right"> <table><td width="23" align="right"> <?php include(DIR_WS_BOXES . 'search2.php'); ?> </td></table> </td> includes/boxes/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 headerBox($info_box_contents); ?> </td> </tr> <!-- categories_header_eof //--> includes/boxes/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(); $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 headerBox($info_box_contents); ?> </td> </tr> <!-- manufacturers_header_eof //--> <?php } ?> includes/boxes/search2.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(); $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 headerBox($info_box_contents); ?> </td> </tr> <!-- manufacturers_header_eof //--> <?php } ?> Added to includes/classes/boxes.php class headerBoxHeading extends tableBox {function headerBoxHeading($contents, $left_corner = true, $right_corner = true, $right_arrow = false) { $this->table_cellpadding = '0'; if ($left_corner == true) { $left_corner = tep_image(DIR_WS_IMAGES . 'pixel_trans.gif.gif'); } else { $left_corner = tep_image(DIR_WS_IMAGES . 'pixel_trans.gif.gif'); } if ($right_arrow == true) { $right_arrow = '<a href="' . $right_arrow . '">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif.gif', ICON_ARROW_RIGHT) . '</a>'; } else { $right_arrow = ''; } if ($right_corner == true) { $right_corner = $right_arrow . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif.gif'); } else { $right_corner = $right_arrow . tep_draw_separator('pixel_trans.gif', '100%', '1'); } $info_box_contents = array(); $info_box_contents[] = array(array('params' => 'height="1" class="headerBoxHeading"', 'text' => $left_corner), array('params' => 'width="100%" height="1" class="headerBoxHeading"', 'text' => $contents[0]['text']), array('params' => 'height="1" class="headerBoxHeading" nowrap', 'text' => $right_corner)); $this->tableBox($info_box_contents, true); } } Added to css: .headerBox {background: #ffffff; } TD.headerBoxHeading { background: #ffffff; } .headerBoxContents { background: #ffffff; } But the mistake is definitely in categories_header.php or manufacturers_header.php, I think. If soemone could track it down and give me an edit, I'll post it up as a contrib. Thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.