rustybolt Posted March 26, 2006 Posted March 26, 2006 im building a motorbike parts online shop i'd like the option of searching by manufacturer of the bike and then the bike model. theres a similar example here but with cars - http://www.pimpmywheels.com if you seach by car and then by model you'll see what i need. can someone please please help ive searched loads on this but cannot find a clear solution any help appreciated thanks russel
Guest Posted March 26, 2006 Posted March 26, 2006 You can do this but paring down and modifying the following files (you can change filenames if you need to keep any of the originals): /includes/boxes/manufacturers.php change: $info_box_contents[] = array('form' => tep_draw_form('manufacturers', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get'), to: $info_box_contents[] = array('form' => tep_draw_form('manufacturers', tep_href_link(FILENAME_ADVANCED_SEARCH, '', 'NONSSL', false), 'get'), In advanced_search_result.php remove all the error checking and redirect at the beginning (lines 17 - 126). Then find: if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) { $where_str .= " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"; } Below it add: if (isset($HTTP_GET_VARS['products_model']) && tep_not_null($HTTP_GET_VARS['products_model'])) { $where_str .= " and p.products_model = '" . $HTTP_GET_VARS['products_model'] . "'"; } Replace advanced_search.php with the following: <?php /* $Id: advanced_search.php,v 1.50 2003/06/05 23:25:46 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH); $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="stylesheet.css"> <script language="javascript" src="includes/general.js"></script> <script language="javascript"><!-- function popupWindow(url) { window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,re sizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,l eft=150') } //--></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><?php echo tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get', 'onSubmit="return check_form(this);"') . tep_hide_session_id(); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE_1; ?></td> <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE_1, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php if ($messageStack->size('search') > 0) { ?> <tr> <td><?php echo $messageStack->output('search'); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $_GET['manufacturers_id'] . "'"); while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { $man_name = $manufacturers['manufacturers_name']; } $model_array = array(array('id' => '', 'text' => 'Model')); $model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where manufacturers_id = '" . $_GET['manufacturers_id'] . "' order by products_model"); while ($model = tep_db_fetch_array($model_query)) { $model_array[] = array('id' => $model['products_model'], 'text' => $model['products_model']); } ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="250" cellspacing="1" cellpadding="2" class="infoBox" align="center"> <tr class="infoBoxContents"> <td><table border="0" width="250" cellspacing="0" cellpadding="2"> <tr> <td class="fieldKey">Selected Make: </td> <td class="fieldKey"><?php echo $man_name; ?></td> </tr> <tr> <td class="fieldKey">Model:</td> <td class="fieldValue"><?php echo tep_draw_pull_down_menu('products_model', $model_array); ?></td> </tr> </table></td> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" align="right"><?php echo tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH); ?></td> </tr> </table></td> </tr> </tr> </table></td> </tr> </table></form></td> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> I only changed/removed what I had to - I am sure they can be cleaned up :) Matti
Guest Posted March 26, 2006 Posted March 26, 2006 You can improve this somewhat by adding the followingto advanced_search_result.php in place of the error checking: $error = false; if (isset($HTTP_GET_VARS['products_model']) && empty($HTTP_GET_VARS['products_model'])) { $error = true; $messageStack->add_session('search', 'Please select the model you are searching for'); $messageStack->add_session('manufacturers_id', $_GET['manufacturers_id']); } if ($error == true) { tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false)); } Then for advanced search.php in my previous post change: <td class="fieldKey"><?php echo $man_name; ?></td> to: <td class="fieldKey"><?php echo $man_name . tep_draw_hidden_field('manufacturers_id', $_GET['manufacturers_id']); ?></td> Enjoy! :) Matti
Recommended Posts
Archived
This topic is now archived and is closed to further replies.