Jump to content

Archived

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

PupStar

New 2.3.1 Infobox

Recommended Posts

I am trying to convert a contribution to 2.3.1 which I have done so previously with success (which will be uploaded to the contribs site once the install docs are written)

 

However this time around I am struggling to understand this error

 

Fatal error: Call to undefined method bm_make_model::check() in C:\wamp\www\catalog\admin\modules.php on line 135

 

which is this line from the code below

 

    function bm_make_model() {

 

I am not quite sure why its saying it is not defined when it clearly is (I think)

 

 

<?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;

            $data = 'Box Content Goes In Here!';

         $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');
   }
   ?>


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

I am trying to convert a contribution to 2.3.1 which I have done so previously with success (which will be uploaded to the contribs site once the install docs are written)

 

However this time around I am struggling to understand this error

 

 

 

which is this line from the code below

 

    function bm_make_model() {

 

I am not quite sure why its saying it is not defined when it clearly is (I think)

 

 

<?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;

            $data = 'Box Content Goes In Here!';

         $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');
   }
   ?>

 

ok panic over I had missed out a } :-"


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

ok panic is not over, for some reason the box will not stay enabled and has now disappeared from the admin>modules>boxes :'(

 

so if anyone could glance over the above box code and let me know if they spot anything wrong please.

 

Thanks

 

Mark


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

You have 1 } in the wrong location, and 1 missing }


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest Responsive osCommerce CE (community edition) here

Share this post


Link to post
Share on other sites

Hi

 

I get it to work like this

 

<?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;

 

$data = 'Box Content Goes In Here!';

 

$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');

}

}

?>

Share this post


Link to post
Share on other sites

Thank you, that worked fine woohoo :thumbsup:


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

ok this is getting a bit trickier now lol

 

Can an array go inside $data ????

 

the code I have is:

 

$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: 100%"') .'<br><br>'.
							    '<span id="model_select">'.tep_draw_pull_down_menu('Model', $Model_array, (isset($Model_selected_var) ? $Model_selected_var : ''), 'onChange="pop_year();" 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>');

 

 

Its the array I dont fully understand what/if it needs changing to something else to go within $data

 

Mark


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

because you close the 'class' with the curly brace after 'execute' method.

(too late ! )


-------------------

Share this post


Link to post
Share on other sites

because you close the 'class' with the curly brace after 'execute' method.

(too late ! )

 

Thanks, that problem is now sorted.

 

I now need to work out how to get the data array etc into the $data

 

Mark


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

ok so far so good, no errors produced at least.

 

Would someone please take a glance over and see if they think its ok.

 

             $data = '<div class="ui-widget infoBoxContainer">' .
                    ' <div class="ui-widget-header infoBoxHeading">' . MODULE_BOXES_MAKE_MODEL_BOX_TITLE . '</div>' .
                    ' ' . $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: 75%"') .' ' .
                    ' <span id="model_select">' . tep_draw_pull_down_menu('Model', $Model_array, (isset($Model_selected_var) ? $Model_selected_var : ''), 'onChange="pop_year();" style="width: 75%"') .'</span>' .
                    ' ' . $hidden_get_variables . tep_hide_session_id() . ' ' .
                    ' <input type="submit" value="Go">   <a href="'.$link.'">Clear Vehicle</a>' .
                    '</div>';

 

Thanks

 

Mark


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

ok so far so good, no errors produced at least.

 

Would someone please take a glance over and see if they think its ok.

 

             $data = '<div class="ui-widget infoBoxContainer">' .
                    ' <div class="ui-widget-header infoBoxHeading">' . MODULE_BOXES_MAKE_MODEL_BOX_TITLE . '</div>' .
                    ' ' . $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: 75%"') .' ' .
                    ' <span id="model_select">' . tep_draw_pull_down_menu('Model', $Model_array, (isset($Model_selected_var) ? $Model_selected_var : ''), 'onChange="pop_year();" style="width: 75%"') .'</span>' .
                    ' ' . $hidden_get_variables . tep_hide_session_id() . ' ' .
                    ' <input type="submit" value="Go">   <a href="'.$link.'">Clear Vehicle</a>' .
                    '</div>';

 

Thanks

 

Mark

 

To comply with xhtml you might want to remove the capitals from onChange

Share this post


Link to post
Share on other sites

Ok so far so good, well I say that as I am not entirely sure if I have got the next bit anywhere near correct (it produces no errors, at least not yet >_< )

 

I am not entirely sure if what I have put in the $data because there is a lot of javascript and arrays before that code.

 

This is the bit that I am most unsure of at the moment:

 

$Make_array[] = array('id' => 'all', 'text' => 'Choose Vehicle');
	$Model_array[] = array('id' => 'all', 'text' => 'Choose Model');
	$Year_array[] = array('id' => 0, 'text' => 'Choose Year');

 

The reason I am unsure is that I presume that the text should appear in the dropdown boxes, alas it does not.

 

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

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

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;

            $data = '<div class="ui-widget infoBoxContainer ">' .
                    ' <div class="ui-widget-header infoBoxHeading">' . MODULE_BOXES_MAKE_MODEL_BOX_TITLE . '</div>' .
                    ' <div class="ui-widget infoBoxContentsSearch"> ' .
                    ' ' . $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: 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() . ' ' .
                    ' <input type="submit" value="Go"><br><a href="'.$link.'">Clear Selection</a>' .
                    '</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');
}
}
?>


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

I knew I was gonna fall foul of these arrays at some point.

 

I have added test data to the database and this error now occurs

 

Warning: reset() expects parameter 1 to be array, null given in C:\wamp\www\catalog\includes\modules\boxes\bm_make_model.php on line 169

 

Warning: Variable passed to each() is not an array or object in C:\wamp\www\catalog\includes\modules\boxes\bm_make_model.php on line 170

 

Mark


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

This worked for me with another box (to make for easier reading):

 

Put all the function stuff in a new file and place it in catalog/includes/functions/XXX.php

 

 

Then call it here

 

function execute() {

global $oscTemplate;

include_once(DIR_WS_FUNCTIONS . FILENAME_XXX);

$data = '<div class="ui-widget infoBoxContainer">'

Share this post


Link to post
Share on other sites

This worked for me with another box (to make for easier reading):

 

Put all the function stuff in a new file and place it in catalog/includes/functions/XXX.php

 

 

Then call it here

 

function execute() {

global $oscTemplate;

include_once(DIR_WS_FUNCTIONS . FILENAME_XXX);

$data = '<div class="ui-widget infoBoxContainer">'

 

Thank you Paul, its now working. I will continue with the conversion tomorrow and fingers crossed it will be ok :blink:


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites
Warning: reset() expects parameter 1 to be array, null given in C:\wamp\www\catalog\includes\functions\make_model.php on line 154

 

Warning: Variable passed to each() is not an array or object in C:\wamp\www\catalog\includes\functions\make_model.php on line 155

 

Ok I finally got back to working on this conversion today although I am still receiving the above errors, not sure why though.

 

This is the code for the function and the code referenced is the last few lines of the file.

 

<?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)) {


 //echo $Make_Model_Year_query;

// Display a drop-down

       $Make_array[] = array('id' => 'all', 'text' => 'Make');
	$Model_array[] = array('id' => 'all', 'text' => 'Model');
	$Year_array[] = array('id' => 0, 'text' => '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: 50%\"><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: 50%\"><option value=\"0\">Choose Year</option></select>";
}
function pop_year(){

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

 

Also when I select the options in the infobox and do the search it returns nothing with this url:

 

localhost/catalog/index.php?Make=Stihl&Model=TS410

however if I change the url to this it works perfectly:

 

localhost/catalog/index.php?Make=Stihl&Model=TS410&manufacturers_id=11

I think this bit has something to do with the seo urls part of the code not working correctly but again am blind to see what.

 

Mark

 

p.s. removed the http:// from the links because they were being shortened.


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

If anyone could offer me some insight into my little problem I would really appreciate it.

 

Thanks

 

Mark


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

Sorry chaps for bumping as I know it is really frowned upon but unfortunately I am no further forward it solving my issues urgh :'(


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

The problem is with using $HTTP_GET_VARS. If you change those to $_GET or declare them in a global statement it should work.

 

That chunk of code is not a function and does not contain functions, so it doesn't belong in the functions directory. Not that it won't work, it's just bad form.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

The problem is with using $HTTP_GET_VARS. If you change those to $_GET or declare them in a global statement it should work.

 

That chunk of code is not a function and does not contain functions, so it doesn't belong in the functions directory. Not that it won't work, it's just bad form.

 

Regards

Jim

 

Hi Jim,

 

What a lifesaver :thumbsup: Many Thanks

 

Any idea about my other problem as to why the search yields no results on the product info page.

 

If you need to see the product_info page then let me know and I will post it.

 

Thanks

 

Mark


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

I don't know about the search. I'm unfamiliar with the Addon that you are modding, so I'm only able to debug PHP errors and simple mistakes. Anything else I'd have to put the code on my system and go through it, and I don't have time for that right now.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

I don't know about the search. I'm unfamiliar with the Addon that you are modding, so I'm only able to debug PHP errors and simple mistakes. Anything else I'd have to put the code on my system and go through it, and I don't have time for that right now.

 

Regards

Jim

 

ok mate thank you anyway, I will battle on.


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

ok I am pretty sure this aint right.

 

The formid is being echo'd in the url

 

//localhost/catalog/index.php?formid=4afbe503fc35abff436645099977a7d8&Make=Stihl&Model=MS170

 

but surely with this code the form id is make_model_year???

 

tep_draw_form('make_model_year', $action, 'get', '', true)

 

or am I way off the mark??? :'(


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

ok I think I have found a problem.

 

when I am on a category page say category 29 and then use the dropdowns to select a make and model from the infobox the urls are not getting cleared (if thats the right way of saying it) so the url becomes

 

//localhost/catalog/index.php?formid=4afbe503fc35abff436645099977a7d8&Make=Stihl&Model=MS170&cPath=29

 

it is appending the &cPath=29 to the end of the url

 

I also have a suspicion that the formid may be coming from somewhere else as well but where that is the question ???

 

Mark


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

×