Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Implementing year make model into header


ediesel

Recommended Posts

I'm trying to add the year make and model box to the header (right bellow the nav. bar). It was originally in column_left.php. I need to move it to right right, and make it horizontal. I've been playing around with it for a few days, and can only get one or two boxes to move over. Here is the code:

 

<div style="float:right;">

<?php
/*
Written by [email protected] on Saturday Jun 20  2009
version 1.5.0
*/

 $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)) {
?>
<!-- year make model //-->
         <tr>
           <td>
<?php
   $info_box_contents = array();
   $info_box_contents[] = array('text'  => '<font color="' . $font_color . '">' . BOX_HEADING_MAKE_MODEL_YEAR . '</font>');
   new infoBoxHeading($info_box_contents, false, false);

// Display a drop-down

       $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">
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: 110px\"><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: 110px\"><option value=\"0\">Choose Year</option></select>";
}
function pop_year(){

var o ="<select name=\"Year\" style=\"width: 110px\" 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);
  }		



     $info_box_contents = array();
  $info_box_contents[] = array("text"  => $javascript); 
     $info_box_contents[] = array('form' => tep_draw_form('make_model_year', $action, 'get'),
                                  'text' =>  tep_draw_pull_down_menu('Make', $Make_array, (isset($Make_selected_var) ? $Make_selected_var : ''), 'onChange="pop_model();"  style="width: 110px"') . '' .
							    '<div Style="" id="model_select">'.tep_draw_pull_down_menu('Model', $Model_array, (isset($Model_selected_var) ? $Model_selected_var : ''), 'onChange="pop_year();" style="width: 110px"') . '</div>' .
							    '<div Style="" 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: 110px"') . '</div>' .
								$hidden_get_variables . tep_hide_session_id() .
								'<input type="submit" value="Search">   <a href="'.$link.'">Clear Vehicle</a>');


   new infoBox($info_box_contents);
?>
           </td>
         </tr>
<!-- year make model_eof //-->
<?php
 }
?>
</div>

 

 

 

It seems like you need to edit this section:

 

      $info_box_contents = array();
  $info_box_contents[] = array("text"  => $javascript); 
     $info_box_contents[] = array('form' => tep_draw_form('make_model_year', $action, 'get'),
                                  'text' =>  tep_draw_pull_down_menu('Make', $Make_array, (isset($Make_selected_var) ? $Make_selected_var : ''), 'onChange="pop_model();"  style="width: 110px"') . '' .
							    '<div Style="" id="model_select">'.tep_draw_pull_down_menu('Model', $Model_array, (isset($Model_selected_var) ? $Model_selected_var : ''), 'onChange="pop_year();" style="width: 110px"') . '</div>' .
							    '<div Style="" 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: 110px"') . '</div>' .
								$hidden_get_variables . tep_hide_session_id() .
								'<input type="submit" value="Search">   <a href="'.$link.'">Clear Vehicle</a>');

 

 

but I'm not 100% sure.... Any help on how to do this would be greatly appreciated!!

 

Here is my website - http://racingpiping.com/en/html/store/

 

I need the YMM to look like this - www.jegs.com

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...