PupStar Posted January 27, 2011 Share Posted January 27, 2011 (edited) Hi Guys, I am really tearing my hair out now with this. I have it working in the admin ok its the catalog side that is causing the problem. Unfortuantely I do not have a link to show you as the site is on localhost on my laptop at the minute. Basically what is happening is that when I select the make and the model and then click 'find' the page just loops back to the index.php page, the url does change however to: http://localhost/catalog/index.php?Make=Ford&Model=Focus The code below is for the info box and the function file (although one member suggested splitting the function and another said it was unnessary, not sure which one is correct so left it the way it is for now) If anyone could spare the time to glance over the code and let me know what they think :blush: Make/Model Infobox in catalog/includes/modules/boxes <?php class bm_make_model { var $code = 'bm_make_model'; var $group = 'boxes'; var $title; var $description; var $sort_order; var $enabled = false; function bm_make_model() { $this->title = MODULE_BOXES_MAKE_MODEL_TITLE; $this->description = MODULE_BOXES_MAKE_MODEL_DESCRIPTION; if ( defined('MODULE_BOXES_MAKE_MODEL_STATUS') ) { $this->sort_order = MODULE_BOXES_MAKE_MODEL_SORT_ORDER; $this->enabled = (MODULE_BOXES_MAKE_MODEL_STATUS == 'True'); $this->group = ((MODULE_BOXES_MAKE_MODEL_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right'); } } function execute() { global $oscTemplate; include_once(DIR_WS_FUNCTIONS . FILENAME_MAKE_MODEL_FUNCTIONS); $data = '<div class="ui-widget infoBoxContainer ">' . ' <div class="ui-widget-header ui-corner-top infoBoxHeading">' . MODULE_BOXES_MAKE_MODEL_BOX_TITLE . '</div>' . ' <div class="ui-widget-content ui-corner-bottom infoBoxContents" style="text-align: center;"> ' . ' ' . MODULE_BOXES_MAKE_MODEL_BOX_DESCRIPTION . ' '. ' ' . $javascript . ' ' . ' ' . tep_draw_form('make_model_year', $action, 'get', '', false) . ' ' . ' ' . tep_draw_pull_down_menu('Make', $Make_array, (isset($Make_selected_var) ? $Make_selected_var : ''), 'onchange="pop_model();" style="width: 85%"') .' ' . ' <span id="model_select">' . tep_draw_pull_down_menu('Model', $Model_array, (isset($Model_selected_var) ? $Model_selected_var : ''), 'onchange="pop_year();" style="width: 85%"') .'</span>' . ' ' . $hidden_get_variables . tep_hide_session_id() . '<br>' . ' ' . tep_draw_button(IMAGE_BUTTON_FIND, 'key', null, 'primary') . '<br>' . ' <a href="'.$link.'">Clear Selection</a>' . ' </form>' . ' </div>' . '</div>'; $oscTemplate->addBlock($data, $this->group); } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_BOXES_MAKE_MODEL_STATUS'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Make/Model Module', 'MODULE_BOXES_MAKE_MODEL_STATUS', 'True', 'Do you want to add the module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_BOXES_MAKE_MODEL_CONTENT_PLACEMENT', 'Left Column', 'Should the module be loaded in the left or right column?', '6', '1', 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_BOXES_MAKE_MODEL_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_BOXES_MAKE_MODEL_STATUS', 'MODULE_BOXES_MAKE_MODEL_CONTENT_PLACEMENT', 'MODULE_BOXES_MAKE_MODEL_SORT_ORDER'); } } ?> Make/Model Functions in catalog/includes/functions <?php $Make_Model_Year_query = tep_db_query("select distinct products_car_make, products_car_model, products_car_year_bof, products_car_year_eof from products_ymm where products_car_make != '' and products_car_model != '' and products_car_year_bof !=0 and products_car_year_eof != 0 order by products_car_make, products_car_model, products_car_year_bof, products_car_year_eof"); if ($number_of_rows = tep_db_num_rows($Make_Model_Year_query)) { // Display a drop-down $Make_array[] = array('id' => 'all', 'text' => 'Choose Brand'); $Model_array[] = array('id' => 'all', 'text' => 'Choose Model'); $Year_array[] = array('id' => 0, 'text' => 'Choose Year'); $javascript = '<script language="javascript" type="text/javascript"> var a = new Array(); var b = new Array(); var c = new Array();'; $y = array(); $M_a = array(); $products_car_make_old = ''; $products_car_model_old = ''; while ($Makes = tep_db_fetch_array($Make_Model_Year_query)) { if (!isset($M_a [$Makes['products_car_make']])) $Make_array[] = array('id' => $Makes['products_car_make'], 'text' => $Makes['products_car_make']); if (!isset($M_a [$Makes['products_car_make']][$Makes['products_car_model']]) && count($y) > 0){ $M_a [$products_car_make_old][$products_car_model_old]=$y; $y = array(); } if ($Makes['products_car_year_bof'] != 0 && $Makes['products_car_year_eof'] != 0){ if ($Makes['products_car_year_bof'] == $Makes['products_car_year_eof']){ $y [$Makes['products_car_year_bof']] = 1; } elseif ($Makes['products_car_year_bof'] < $Makes['products_car_year_eof']){ while ($Makes['products_car_year_bof'] <= $Makes['products_car_year_eof']){ $y [$Makes['products_car_year_bof']] = 1; $Makes['products_car_year_bof']++; } } } $products_car_make_old = $Makes['products_car_make']; $products_car_model_old = $Makes['products_car_model']; $M_a [$Makes['products_car_make']][$Makes['products_car_model']] = array(); } $M_a [$products_car_make_old][$products_car_model_old]=$y; $i = 0; foreach ($M_a as $k =>$v){ $javascript .= 'a['.$i.']="'.$k.'";b['.$i.']=new Array('; $ii = 0; $s = ''; foreach ($M_a[$k] as $kk =>$vv){ $javascript .= ($ii != 0 ? ',' : '').'"'.$kk.'"'; $ss = ''; $iii = 0; foreach ($M_a[$k][$kk] as $kkk => $vvv){ $ss .= ($iii != 0 ? ',' : '').$kkk; $iii++; } if ($iii == 1) $ss = '"'.$ss.'"'; $s .= 'c['.$i.']['.$ii.']=new Array('.$ss.');'; $ii++; } $javascript .= ');c['.$i.']=new Array();'.$s; $i++; } $javascript .= ' function pop_model(){ var o ="<select name=\"Model\" onChange=\"pop_year();\" style=\"width: 100%\"><option value=\"all\">Choose Model</option>"; var sv = document.make_model_year.Make.value; if(sv != "all"){ var v = a.length; while(v--) if(sv == a[v]) break; for(var i = 0; i < b[v].length; i++) o+="<option value=\""+b[v][i]+"\">"+b[v][i]+"</option>"; } o+="</select>"; document.getElementById("model_select").innerHTML= o; document.getElementById("year_select").innerHTML= "<select name=\"Year\" style=\"width: 100%\"><option value=\"0\">Choose Year</option></select>"; } function pop_year(){ var o ="<select name=\"Year\" style=\"width: 100%\" onChange=\"document.make_model_year.submit();\"><option value=\"0\">Choose Year</option>"; var sv = document.make_model_year.Make.value; if(sv != "all"){ var v = a.length; while(v--) if(sv == a[v]) break; var sv2 = document.make_model_year.Model.value; if(sv2 != "all"){ var v2 = b[v].length; while(v2--) if(sv2 == b[v][v2]) break; for(var i = 0; i < c[v][v2].length; i++) o+="<option value=\""+c[v][v2][i]+"\">"+c[v][v2][i]+"</option>"; } } o+="</select>"; document.getElementById("year_select").innerHTML= o; } </script>'; if (isset($Make_selected_var) && isset($M_a[$Make_selected_var])){ foreach ($M_a[$Make_selected_var] as $k => $v) $Model_array[] = array('id' => $k, 'text' => $k);} if (isset($Make_selected_var) && isset($Model_selected_var) && isset($M_a[$Make_selected_var][$Model_selected_var])) foreach ($M_a[$Make_selected_var][$Model_selected_var] as $k => $v) $Year_array[] = array('id' => $k, 'text' => $k); $script = basename($_SERVER['SCRIPT_NAME']); if ($script == 'index.php' && (!isset($cPath) || $cPath == '')){ if (defined('FILENAME_ALLPRODS_SEO') && ALL_PRODUCTS_SEO == 'true'){ $script = FILENAME_ALLPRODS_SEO ; } elseif (defined('ALL_PRODUCTS') && ALL_PRODUCTS == 'true'){ $script = FILENAME_ALLPRODS ; } } $hidden_get_variables = ''; $keys = Array('Year','Make','Model',tep_session_name(),'x','y'); if ($script == 'product_info.php'){ if(isset($cPath) || $cPath != ''){ $_GET['cPath'] = $cPath; $link = 'index.php?cPath='.$cPath.'&Make=all&Model=all&Year=0'; } else { $link = 'index.php?Make=all&Model=all&Year=0'; } $action = 'index.php'; $keys [] = 'products_id'; } elseif (SEO_ENABLED == 'true' && basename($PHP_SELF) != FILENAME_ADVANCED_SEARCH_RESULT){ $action = tep_href_link($script, tep_get_all_get_params(array('Make','Model','Year')), 'NONSSL', false); $link = tep_href_link($script, tep_get_all_get_params(array('Make','Model','Year')).'Make=all&Model=all&Year=0', 'NONSSL', false); $keys [] = 'cPath'; $keys [] = 'products_id'; $keys [] = 'manufacturers_id'; } else { $action = $script; $link = $script.'?'.tep_get_all_get_params(array('Make','Model','Year')).'Make=all&Model=all&Year=0'; } reset($_GET); while (list($key, $value) = each($_GET)) { if (!in_array($key,$keys)) $hidden_get_variables .= tep_draw_hidden_field($key, $value); } } ?> Edited January 27, 2011 by PupStar Quote Link to comment Share on other sites More sharing options...
Guest Posted February 10, 2011 Share Posted February 10, 2011 (edited) Mark, The updated version can be found here http://addons.oscommerce.com/info/7835 ps. The problem is you need to change the coding in application_top.php and general.php so it works with the query in 2.3.1 Chris Edited February 10, 2011 by DunWeb Quote Link to comment Share on other sites More sharing options...
_Keith_ Posted February 19, 2012 Share Posted February 19, 2012 Anyone know where I can get the already populated make and models? Quote Link to comment Share on other sites More sharing options...
Guest Posted February 20, 2012 Share Posted February 20, 2012 @_Keith_ There is no already populated contribution. You have to add them yourself. Chris Quote Link to comment Share on other sites More sharing options...
_Keith_ Posted February 23, 2012 Share Posted February 23, 2012 Im also having another problem. I set the placement of it. And it does not move from the bottom. Quote Link to comment Share on other sites More sharing options...
_Keith_ Posted February 23, 2012 Share Posted February 23, 2012 @_Keith_ There is no already populated contribution. You have to add them yourself. Chris Holy crap.... Anyone have this populated already? Quote Link to comment Share on other sites More sharing options...
Guest Posted February 23, 2012 Share Posted February 23, 2012 I don't think anyone will have a pre-populated database for you as the contribution is designed to be customized for each store. However, someone might see this and offer their SQL statement which you will more than likely have to edit anyway to suit your needs. Chris Quote Link to comment Share on other sites More sharing options...
_Keith_ Posted February 23, 2012 Share Posted February 23, 2012 Im setting up a full online store. So all makes and models need to be in the system. Quote Link to comment Share on other sites More sharing options...
_Keith_ Posted February 23, 2012 Share Posted February 23, 2012 Im also having another problem. I set the placement of it. And it does not move from the bottom. Any help with this? Quote Link to comment Share on other sites More sharing options...
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.