Jump to content

amarangos

Members
  • Content count

    3
  • Joined

  • Last visited

2 Followers

Profile Information

  • Real Name
    Deez
  • Gender
    Male
  1. Any chance you would like to share what you changed in the code?
  2. To Dunweb: Me again, I made some changes to bm_make_model_year.php so that it is more XHTML 1.0 Transitional WC3 compliant as I was recently validating my test site. Nothing crazy, just a couple of & instead of &, //<![CDATA[ in the javascript, and a couple of </br>. The minor changes helped me clean up a majority of the errors I was getting. Figured I would share what I changed: To everyone else, feel free to use this at your own risk, I wouldn't use this on a production site until Dunweb has a chance to look at it and approve/disapprove, perhaps incorporate it into the next release. <?php class bm_year_make_model { var $code = 'bm_year_make_model'; var $group = 'boxes'; var $title; var $description; var $sort_order; var $enabled = false; function bm_year_make_model() { $this->title = MODULE_BOXES_YEAR_MAKE_MODEL_TITLE; $this->description = MODULE_BOXES_YEAR_MAKE_MODEL_DESCRIPTION; if ( defined('MODULE_BOXES_YEAR_MAKE_MODEL_STATUS') ) { $this->sort_order = MODULE_BOXES_YEAR_MAKE_MODEL_SORT_ORDER; $this->enabled = (MODULE_BOXES_YEAR_MAKE_MODEL_STATUS == 'True'); $this->group = ((MODULE_BOXES_YEAR_MAKE_MODEL_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right'); } } function execute() { global $HTTP_GET_VARS, $languages_id, $currencies, $oscTemplate, $Make_selected_var, $Model_selected_var, $Year_selected_var; $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)) { $ymm_list = '<div class="ui-widget infoBoxContainer">' . ' <div class="ui-widget-header infoBoxHeading">'. MODULE_BOXES_YEAR_MAKE_MODEL_TITLE . '</div>'; $ymm_list .= '<div class="ui-widget-content infoBoxContents" style="text-align: center;">'; $Make_array[] = array('id' => 'all', 'text' => 'Choose Vehicle'); $Model_array[] = array('id' => 'all', 'text' => 'Choose Model'); $Year_array[] = array('id' => 0, 'text' => 'Choose Year'); $javascript = '<script language="javascript" type="text/javascript"> //<![CDATA[ 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 != ''){ $HTTP_GET_VARS['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($HTTP_GET_VARS); while (list($key, $value) = each($HTTP_GET_VARS)) { if (!in_array($key,$keys)) $hidden_get_variables .= tep_draw_hidden_field($key, $value); } } $ymm_list .= $javascript.tep_draw_form('make_model_year', $action, 'get').tep_draw_pull_down_menu('Make', $Make_array, (isset($Make_selected_var) ? $Make_selected_var : ''), 'onChange="pop_model();" style="width: 100%"') .'<br/><br/>'. '<span id="model_select">'.tep_draw_pull_down_menu('Model', $Model_array, (isset($Model_selected_var) ? $Model_selected_var : ''), 'style="width: 100%"') .'</span><br/><br/>'. '<span id="year_select">'.tep_draw_pull_down_menu('Year', $Year_array, (isset($Year_selected_var) ? $Year_selected_var : ''), 'onChange="document.make_model_year.submit();" style="width: 100%"') .'</span><br/><br/>'. $hidden_get_variables . tep_hide_session_id() . '<input type="submit" value="Go"> <a href="'.$link.'/>">Clear Vehicle</a></form>'; $ymm_list .= ' </div>' . '</div>'; $oscTemplate->addBlock($ymm_list, $this->group); } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_BOXES_YEAR_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 Year Make Model Module', 'MODULE_BOXES_YEAR_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_YEAR_MAKE_MODEL_CONTENT_PLACEMENT', 'Right 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_YEAR_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_YEAR_MAKE_MODEL_STATUS', 'MODULE_BOXES_YEAR_MAKE_MODEL_CONTENT_PLACEMENT', 'MODULE_BOXES_YEAR_MAKE_MODEL_SORT_ORDER'); } } ?>
  3. To Dunweb: In bm_year_make_model.php find the following line $javascript = '<script language="javascript" type="text/javascript"> var a = new Array(); var b = new Array(); var c = new Array();'; and change it to $javascript = '<script language="javascript" type="text/javascript"> //<![CDATA[ var a = new Array(); var b = new Array(); var c = new Array();';
×