Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Dropdown filters not working, can not work out why


PupStar

Recommended Posts

Hi Guys,

 

I am converting my modified code based on this contribution http://addons.oscommerce.com/info/7116

 

Now the bit I am struggling to understand why it does not work on 2.3.4 bootstrap

 

The code is:

<?php
require('includes/application_top.php');

if(isset($_REQUEST['filterid'])&&($_REQUEST['filterid']!='')) {
 $filterid = $_REQUEST['filterid'];
	$filterquery = tep_db_query("select * from ".TABLE_PRINTER_CATEGORY."  where parent_id = '0' AND printer_category_id = '".$filterid."'");
	if(tep_db_num_rows($filterquery)>0) {
      $showfilter = true;
    }
}

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_FILTER_PRINTER);
  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_FILTER_PRINTER_FINDER));
  require(DIR_WS_INCLUDES . 'template_top.php');
?>

<?php if($showfilter) { ?>

<div class="panel panel-default">
 <div class="panel-body">
   <div>
    <div class="col-md-6"><?php getprintercatoptions($filterid); ?></div>
    <div class="col-md-6"><?php echo TEXT_PARTS_FINDER_DESCRIPTION;?></div>
   </div>
  </div>
 </div>

 <?php
							$printerid = 0;
							if(isset($_REQUEST['mode'])&&($_REQUEST['mode']=='showlist'))
							{
								$printerid= $_REQUEST['part_cat_'.$filterid];
							}
							elseif(isset($_REQUEST['mode'])&&($_REQUEST['mode']=='searchlist'))
							{
							    $query = tep_db_query("SELECT printer_category_id FROM ".TABLE_PRINTER_CATEGORY." where category_name = '".$_REQUEST['keywords']."'");
							    $vehidrow = tep_db_fetch_array($query);

								if($vehidrow['printer_category_id']!='')
								{
									$printerid= $vehidrow['printer_category_id'];
									$printerid= $vehidrow['categories_image'];
								}
							}

						$define_list = array('PRODUCT_LIST_MEDIACAT_PART_NO' => PRODUCT_LIST_MEDIACAT_PART_NO,
                                             'PRODUCT_LIST_MEDIACAT_QUANTITY' => PRODUCT_LIST_MEDIACAT_QUANTITY,
                    						 'PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
                                             'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
                                             'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
                                             'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
                                             'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
                                             'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
                                             'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

						asort($define_list);

						$column_list = array();
						reset($define_list);
						while (list($key, $value) = each($define_list)) {
						  if ($value > 0) $column_list[] = $key;
						}
						 $select_column_list = '';

						for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
						  switch ($column_list[$i]) {
							case 'PRODUCT_LIST_NAME':
							  $select_column_list .= 'pd.products_name, ';
							  break;
							case 'PRODUCT_LIST_MANUFACTURER':
							  $select_column_list .= 'm.manufacturers_name, ';
							  break;
							case 'PRODUCT_LIST_QUANTITY':
							  $select_column_list .= 'p.products_quantity, ';
							  break;
							case 'PRODUCT_LIST_IMAGE':
							  $select_column_list .= 'p.products_image, ';
							  break;
							case 'PRODUCT_LIST_WEIGHT':
							  $select_column_list .= 'p.products_weight, ';
							  break;
						  }
						}
						if($printerid>0)
						{
							$printercat_query = tep_db_query("SELECT * FROM ".TABLE_PRINTER_CATEGORY." WHERE printer_category_id = '".$printerid."'");
							$printercat_row = tep_db_fetch_array($printercat_query);
							$productids = $printercat_row['productids'];
							if($productids!='')
							{
								$listing_sql = "select distinct " . $select_column_list . " p.products_id, p.products_mediacat_ref_no, p.manufacturers_id, p.products_price, pd.mediacat_part_no, products_mediacat_quantity, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and FIND_IN_SET(p.products_id,'".$productids."' )";
								$listing_sql .= " order by pd.products_id";
							}
						?>

						<?php
						$catimage_query = tep_db_query("select categories_image, categories_image_large, category_image_name, category_imagemap_name FROM ".TABLE_PRINTER_CATEGORY." WHERE printer_category_id = '".$printerid."'");
						 while ($category_image = tep_db_fetch_array($catimage_query)) {

							if($productids!='')	{
							$imagemap = $category_image['category_imagemap_name'];

							echo '<div class="alert alert-info">' . $category_image['category_image_name'] . '</div>';
							echo '<div class="row">';
							echo ' <div class="col-md-6 col-sm-6 col-xs-12">';
							echo '<div class="sp-loading"><img src="images/sp-loading.gif" alt=""><br>LOADING IMAGES</div>';
							echo '	<div class="sp-wrap"><a href="'.tep_href_link(DIR_WS_IMAGES_PARTS . $category_image['categories_image_large']).'">' . tep_image_maps(DIR_WS_IMAGES_PARTS . $category_image['categories_image'], NULL, NULL, 'class="img-responsive"') . '</a></div>';
							echo ' </div>';
							echo ' <div class="col-md-6 col-sm-6 col-xs-12">';
		                            include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING_LIST);
							echo ' </div>';
							echo '</div>';

							}else if (isset($category_image['categories_image'])) {
							echo '<div>' . $category_image['category_image_name'] . '</div>';
							echo '<div><a href="'.tep_href_link(DIR_WS_IMAGES . $category_image['categories_image']).'">' . tep_image_maps(DIR_WS_IMAGES . $category_image['categories_image'], NULL, NULL, 'class="img-responsive"') . '</a></div>';
		}
	   }
  	  }
     }
?>

<?php
function getprintercatoptions($printer_category_id="",$curprintercatid="")
{

	$fieldid = $printer_category_id;
	if(isset($_REQUEST['part_cat_'.$printer_category_id])&&($_REQUEST['part_cat_'.$printer_category_id]!=''))
	{

		 $printer_category_id = $_REQUEST['part_cat_'.$printer_category_id];
		  $str = getprintercatpath($printer_category_id,"");


		 $query1 = tep_db_query("SELECT count(printer_category_id) FROM " . TABLE_PRINTER_CATEGORY . "  where parent_id = '".$printer_category_id."'");

		 $chkbottomROW = tep_db_fetch_array($query1);


		 if($str =="") {$str = "0,";}
		 if($chkbottomROW[0]>0)
		 {
		 	$str .= $printer_category_id.",";
		 }

		$catarr = explode(",",substr($str,0,-1));
		sort($catarr);
		editprintercat($catarr,$fieldid,$printer_category_id,$curprintercatid);
	}
	else
	{

		if($curprintercatid>0)
		{
			 $str = getprintercatpath($curprintercatid,"");
			if($str =="")
			{$str = $curprintercatid.",";}
			else
			{
				$str .= $curprintercatid.",";
			}

		}
		else
		{
			$str = getprintercatpath($printer_category_id,"");
			if($str =="") {$str = $printer_category_id.",";}
		}

		$catarr = explode(",",substr($str,0,-1));
		sort($catarr);
		editprintercat($catarr,$fieldid,$printer_category_id,$curprintercatid);
	}

}
function editprintercat($catarr,$fieldid,$printer_category_id,$curprintercatid="")
{
	?>
	<?php
	$i=0;
	$cntvarr = count($catarr);
	foreach($catarr as $val)
	{
		$veh_cat_array = array(array('id' => '', 'text' => 'Please Select'));

		$printers_query = tep_db_query("select * from " . TABLE_PRINTER_CATEGORY . "  where parent_id = '".$val."' order by category_name");
		if(tep_db_num_rows($printers_query)>0)
		{
			while ($printers = tep_db_fetch_array($printers_query))
			{
				$veh_cat_array[] = array('id' => $printers['printer_category_id'],
										 'text' => $printers['category_name']);
			}
			?>
			<?php
			if($cntvarr==$i+1)
			{
				 $selval = $printer_category_id;
			}

			else
			{
				$selval = $catarr[$i+1];
			}
?>


			<div data-toggle="dropdown">
             <?php echo tep_draw_pull_down_menu_parts('part_cat_'.$val, $veh_cat_array, $selval, 'onchange="document.frmveh.part_cat_'.$fieldid.'.value=this.value;document.frmveh.submit();"');?>
			</div>
			<?php
			$i++;
		}
	}
?>

<?php
}

function getprintercatpath($printer_category_id, $str)
{

	$str1 = $str;

	$printers_query = tep_db_query("select parent_id from " . TABLE_PRINTER_CATEGORY . "  where printer_category_id = '".$printer_category_id."'");
	$printers = tep_db_fetch_array($printers_query);
	 $parent_id = $printers['parent_id'];
	if($parent_id==0)
	{
		return  $str1;
	}
	else
	{
		$str1 .= $parent_id.",";
		$str1 = getprintercatpath($parent_id, $str1);
		return $str1;
 }
}
?>

<form name="frmveh" action="" method="get">
<input type="hidden" name="part_cat_<?php echo $filterid;?>" value="<?php echo $_REQUEST['part_cat_1'];?>">
<input type="hidden" name="filterid" value="<?php echo $filterid;?>" />
<input type="hidden" name="mode" value="showlist" />
</form>

<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

If I comment out these lines

$filterid = $_REQUEST['filterid'];

<?php if($showfilter) { ?>

and the corresponding closing }

The page displays as it should but the dropdowns dont work which brings me to the ajax code which will be the next question if I can get this one resolved.

 

Any ideas guys as I am going around in circles with this now.

 

Thanks

 

Mark

Link to comment
Share on other sites

Hi -

 

sounds like maybe a javascript problem - have a look in the dev tools/console of the browser and see if it reports anything, if not then

 

double check that the page is loading just one copy of the required files (bootstrap javascript and jquery). Also check that if you are pulling from a CDN that the bootstrap version has not changed and your bootstrap files are all for the same version.

 

If still no joy can you show the generated html for the non-working page?

Link to comment
Share on other sites

Hi -

 

sounds like maybe a javascript problem - have a look in the dev tools/console of the browser and see if it reports anything, if not then

 

double check that the page is loading just one copy of the required files (bootstrap javascript and jquery). Also check that if you are pulling from a CDN that the bootstrap version has not changed and your bootstrap files are all for the same version.

 

If still no joy can you show the generated html for the non-working page?

 

@@Bob Terveuren

 

Hi Bob,

 

I had a look in firebug under the console tab and it only tells me this

 

The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page.

 

The source for the page is this

<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Hobbit</title>
<base href="http://localhost/hobbit/'>http://localhost/hobbit/">

<link href="ext/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="ext/smoothproducts/css/smoothproducts.css">
<link href="custom.css" rel="stylesheet">
<link href="user.css" rel="stylesheet">

<!--[if lt IE 9]>
   <script src="ext/js/html5shiv.js"></script>
   <script src="ext/js/respond.min.js"></script>
   <script src="ext/js/excanvas.min.js"></script>
<![endif]-->

<script src="ext/jquery/jquery-1.11.1.min.js"></script>

<script src="ext/jquery/jquery.mobile.custom.min.js"></script>

<script type="text/javascript" language="javascript" src="ext/jquery/jquery.ajaxq-0.0.1.js"></script>

  <script>
    $(document).ready(function() {
      $("#myCarousel").swiperight(function() {
        $(this).carousel('prev');
      });
      $("#myCarousel").swipeleft(function() {
        $(this).carousel('next');
      });
    });
  </script>

<!-- font awesome -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<noscript><div class="no-script"><div class="no-script-inner"><p><strong>JavaScript seems to be disabled in your browser.</strong></p><p>You must have JavaScript enabled in your browser to utilize the functionality of this website. <a href="http://www.enable-javascript.com/" target="_blank" rel="nofollow">Click here for instructions on enabling javascript in your browser</a>.</div></div></noscript>
<style>.no-script { border: 1px solid #ddd; border-width: 0 0 1px; background: #ffff90; font: 14px verdana; line-height: 2; text-align: center; color: #2f2f2f; } .no-script .no-script-inner { margin: 0 auto; padding: 5px; } .no-script p { margin: 0; }</style></head>
<body>

  <nav class="navbar navbar-fixed-top navbar-inverse navbar-no-corners navbar-no-margin" role="navigation">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-navbar-collapse-1">
        <span class="sr-only">Toggle Navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <div class="collapse navbar-collapse" id="bs-navbar-collapse-1">
      <div class="container-fluid">
        <ul class="nav navbar-nav">
          <li><a class="store-brand" href="http://localhost/hobbit/'>http://localhost/hobbit/index.php"><i class="fa fa-home fa-lg"></i><span class="hidden-sm"> Home</span></a></li>          <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/products_new.php"><i class="fa fa-bullhorn fa-lg"></i><span class="hidden-sm">  New Products</span></a></li>          <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/specials.php"><i class="fa fa-magic fa-lg"></i><span class="hidden-sm"> Special Offers</span></a></li>          <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/reviews.php"><i class="fa fa-comments-o fa-lg"></i><span class="hidden-sm"> Reviews</span></a></li>        </ul>
        <ul class="nav navbar-nav navbar-right">
                      <li class="dropdown">
              <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-cogs fa-lg"></i><span class="hidden-sm"> Currency</span> <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li class="text-center text-muted bg-primary"><abbr title="Selected Language">L:</abbr> English <abbr title="Selected Currency">C:</abbr> GBP</li>
                              </ul>
            </li>
                      <li class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-users fa-lg"></i><span class="hidden-sm"> My Account</span> <span class="caret"></span></a>
            <ul class="dropdown-menu">
              <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/login.php"><i class="fa fa-user"></i> Log In</a><li><a href="http://localhost/hobbit/'>http://localhost/hobbit/create_account.php"><i class="fa fa-pencil-square-o"></i> Register</a>              <li class="divider"></li>
              <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/account.php">My Account</a></li>
              <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/account_history.php">My Orders</a></li>
              <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/address_book.php">My Address Book</a></li>
              <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/account_password.php">My Password</a></li>
            </ul>
          </li>
          <li class="nav navbar-text"><i class="fa fa-shopping-cart fa-lg"></i> 0 items</li>        </ul>
      </div>
    </div>
  </div>
</nav>

  <div id="bodyWrapper" class="container">
    <div class="row">

      
<div class="modular-header">
  <div id="storeLogo" class="col-sm-8">
  <a href="http://localhost/hobbit/'>http://localhost/hobbit/index.php"><img src="images/store_logo.png" alt="The Hobbit" title="The Hobbit" width="200" height="50" class="img-responsive" /></a></div>
<div class="clearfix"></div>
<div class="col-sm-12">
 <nav class="navbar navbar-default navbar-no-margin" role="navigation">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-navbar-collapse">
          <span class="sr-only">Toggle Navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>

      <div class="collapse navbar-collapse" id="bs-navbar-collapse">
        <div class="container-fluid">
          <div><ul class="nav navbar-nav"><li><a href="http://localhost/hobbit/'>http://localhost/hobbit/index.php?cPath=7">Guide Bars & Chains</a></li><li class="dropdown"><a href="#" tabindex="-1" class="dropdown-toggle" data-hover="dropdown">Spare Parts<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="http://localhost/hobbit/'>http://localhost/hobbit/index.php?cPath=1"></a></li><li class="dropdown dropdown-submenu"><a href="#" tabindex="-1" class="dropdown-toggle" data-toggle="dropdown">Viking</a><ul class="dropdown-menu"><li><a href="http://localhost/hobbit/'>http://localhost/hobbit/index.php?cPath=1_2"></a></li><li class="dropdown dropdown-submenu"><a href="#" tabindex="-1" class="dropdown-toggle" data-toggle="dropdown">Lawnmowers</a><ul class="dropdown-menu"><li><a href="http://localhost/hobbit/'>http://localhost/hobbit/index.php?cPath=1_2_3"></a></li><li class="dropdown dropdown-submenu"><a href="#" tabindex="-1" class="dropdown-toggle" data-toggle="dropdown">Viking MB248.1</a><ul class="dropdown-menu"><li><a href="http://localhost/hobbit/'>http://localhost/hobbit/index.php?cPath=1_2_3_4"></a></li><li><a href="http://localhost/hobbit/'>http://localhost/hobbit/index.php?cPath=1_2_3_4_5">Handle</a></li><li><a href="http://localhost/hobbit/'>http://localhost/hobbit/index.php?cPath=1_2_3_4_6">Housing</a></li></ul></li></ul></li></ul></li></ul></li></ul></div>
          <div class="col-sm-offset-4 col-sm-4"><div class="searchbox-margin"><form name="quick_find" action="http://localhost/hobbit/'>http://localhost/hobbit/advanced_search_result.php" method="get" class="form-horizontal">  <div class="input-group"><input type="text" name="keywords" required placeholder="Search" class="form-control" /><span class="input-group-btn"><button type="submit" class="btn btn-success"><i class="fa fa-search"></i></button></span>  </div></form></div></div>
        </div>
      </div>
    </nav>
</div>
  <div class="col-sm-12 visible-lg">
   <div class="nav navbar-nav breadcrumb-margin">
     <div id="bc2" class="btn-group btn-breadcrumb"><a itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="btn btn-default" href="http://localhost" itemprop="url"><div itemprop="title"><i class="fa fa-home fa-lg"></i></div></a><div class="btn btn-default" style="display: none;">...</div><a itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="btn btn-default" href="http://localhost/hobbit/'>http://localhost/hobbit/index.php" itemprop="url"><div itemprop="title">Catalog</div></a><a itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="btn btn-default" href="http://localhost/hobbit/'>http://localhost/hobbit/parts_finder.php?filterid=1" itemprop="url"><div itemprop="title">Horticultural Machinery Parts Finder</div></a></div>  </div>
</div>

<div class="header col-sm-12 visible-lg">
  </div>

</div>

<div class="body-sans-header clearfix">


      <div id="bodyContent" class="col-md-12 ">



<form name="frmveh" action="" method="get">
<input type="hidden" name="part_cat_1" value="">
<input type="hidden" name="filterid" value="1" />
<input type="hidden" name="mode" value="showlist" />
</form>


      </div> <!-- bodyContent //-->


    </div> <!-- row -->

  </div> <!-- bodyWrapper //-->

  
</div>

<footer>
  <div class="footer">
    <div class="container">
      <div class="row">
        <div class="col-sm-3 visible-lg">
  <div class="footerbox contact">
    <h2>How To Contact Us</h2>
    <address>
      The Hobbit<br>
      Address Line 1<br />
Address Line 2<br />
Country<br />
Phone<br>
      <abbr title="Phone">P:</abbr> 555-1234<br>
      <abbr title="Email">E:</abbr> [email protected]    </address>

  </div>
</div>

<div class="col-sm-3 visible-lg">
  <div class="footerbox information">
    <h2>Information</h2>
    <ul class="list-unstyled">
      <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/shipping.php">Shipping & Returns</a></li>
      <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/privacy.php">Privacy & Cookie Policy</a></li>
      <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/conditions.php">Terms & Conditions</a></li>
      <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/contact_us.php">Contact Us</a></li>
    </ul>
  </div>
</div>

<div class="col-sm-3 visible-lg">
  <div class="footerbox generic-text">
    <h2>About Us</h2>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>  </div>
</div>

<div class="col-sm-3 visible-lg">
  <div class="footerbox account">
    <h2>Customer Services</h2>
    <ul class="list-unstyled">
      <li><a href="http://localhost/hobbit/'>http://localhost/hobbit/account.php">My Account</a></li><li><a href="http://localhost/hobbit/'>http://localhost/hobbit/address_book.php">My Address Book</a></li><li><a href="http://localhost/hobbit/'>http://localhost/hobbit/account_history.php">My Order History</a></li>    </ul>
  </div>
</div>
      </div>
    </div>
  </div>
  <div class="footer-extra">
    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-3 text-right text-center-xs footer-suffix">
  
  <p>
    <i class="fa fa-mobile fa-2x"></i>
    <i class="fa fa-tablet fa-2x"></i>
    <i class="fa fa-laptop fa-2x"></i>
    <i class="fa fa-desktop fa-2x"></i>
  </p></div>

<div class="col-sm-5 text-center-xs footer-suffix">
  <p>Copyright © 2015 <a href="http://localhost/hobbit/'>http://localhost/hobbit/index.php">The Hobbit</a> Powered by <a href="http://www.oscommerce.com" target="_blank">osCommerce</a></p></div>
<div class="col-sm-4 text-right text-center-xs footer-suffix">
  
  <p>
    <i class="fa fa-cc fa-2x"></i>
    <i class="fa fa-cc-amex fa-2x"></i>
    <i class="fa fa-cc-discover fa-2x"></i>
    <i class="fa fa-cc-mastercard fa-2x"></i>
    <i class="fa fa-cc-paypal fa-2x"></i>
    <i class="fa fa-cc-stripe fa-2x"></i>
    <i class="fa fa-cc-visa fa-2x"></i>
  </p></div>
      </div>
    </div>
  </div>
</footer>



<script src="ext/bootstrap/js/bootstrap.min.js"></script>
<script src="ext/bootstrap/js/bootstrap-hover-dropdown.min.js"></script>
<script src="ext/js/ajaxd.js" ></script>
<script type="text/javascript" src="ext/smoothproducts/js/smoothproducts.min.js"></script>
<script type="text/javascript">
    /* wait for images to load */
    $(window).load( function() {
        $('.sp-wrap').smoothproducts();
    });
</script>


</body>
</html>

as you can see the entire section of code which displays the dropdowns etc is omitted because of the filterid problem.

 

Mark

Link to comment
Share on other sites

Hi

 

I think two problems here -

 

(1) Dropdown is bust

 

if I grab a copy of the addon and pop the sql etc into a vanilla 234bs then your page code above will  throw an error as it cannot find tep_draw_pull_down_menu_parts() - however if I edit that to tep_draw_pull_down_menu() I get a working dropdown with this HTML


             <select name="part_cat_1" onchange="document.frmveh.part_cat_1.value=this.value;document.frmveh.submit();" class="form-control">
                 <option value="">Please Select</option>
                 <option value="2969">Apple</option>
                 <option value="2">Brother</option>
                 
             </select>			

Have a look at your function that draws the dropdown and see what it produces - although (2) may fix that too

 

(2) The page fails to display unless you edit this code:

if(isset($_REQUEST['filterid'])&&($_REQUEST['filterid']!='')) {
 $filterid = $_REQUEST['filterid'];
	$filterquery = tep_db_query("select * from ".TABLE_PRINTER_CATEGORY."  where parent_id = '0' AND printer_category_id = '".$filterid."'");
	if(tep_db_num_rows($filterquery)>0) {
      $showfilter = true;
    }
}

The way the original code is written means that it relies on the printer_category table holding an entry that has a parent_id of zero and a printer_category_id of 1 (look at his edits to includes/filenames.php) it may be that you no longer have those in the table so you'll see a blank page unless you get ?filterid=xx in your url where xx is the printer_category_id of your default 'top' category in that table (i.e. it needs a parent_id of zero).

 

There'se a couple of changes below that you could try in your file - they're a bit rushed and I also think the original code lacks somewhat but here you go:

 

Change the top of the file to this

require('includes/application_top.php');

$showfilter=false;

if(isset($_REQUEST['filterid'])&&($_REQUEST['filterid']!='')) {
 $filterid = $_REQUEST['filterid'];
	$filterquery = tep_db_query("select * from ".TABLE_PRINTER_CATEGORY."  where parent_id = '0' AND printer_category_id = '".$filterid."'");
	if(tep_db_num_rows($filterquery)>0) {
       $showfilter = true;
    }
}
if ($showfilter==false){
	//nothing seen in the $_REQUEST so try and get the top most category that has a parent_id of zero
	$filterquery_new = tep_db_query("select * from ".TABLE_PRINTER_CATEGORY."  where parent_id = '0' order by printer_category_id asc limit 1");
	if(tep_db_num_rows($filterquery_new)>0) {
       $showfilter = true;
	   $filter_result=tep_db_fetch_array($filterquery_new);
	   $filterid = ($filter_result['printer_category_id']);
    }
	
}

If the above does not pickup a valur for filterid as you have no category with a parent_id of zero then you can at least get a bit of somethiing displayed  by popping the code below in above function getprintercatoptions

     //new stuff
     else{
         echo 'Default stuff here';
        
     }
?>

<?php
function getprintercatoptions($printer_category_id="",$curprintercatid="")

I'm not too sure that most of this could be done by coding into the 'real' categories table ???

Link to comment
Share on other sites

@Bob Terveuren

 

Thanks for the help Bob :thumbsup:

 

Strangely enough I do have 3 categories with a parent_id of 0 (see attached image) but it does not see them for some reason

 

I do have this working great on an old 2.3.2 version that is why I am stumped urgh

 

 

 

 

 

 

Link to comment
Share on other sites

Hi

 

I was using the default data that came in the addon - that has a top category of 1 (hence the filterid=1 in the code). If I enter data using the admin (as you have there) - it gets a top category of zero.

 

To get that displaying change the top of the file to this


$showfilter=false;

if(isset($_REQUEST['filterid'])&&($_REQUEST['filterid']!='')) {
 $filterid = $_REQUEST['filterid'];
	$filterquery = tep_db_query("select * from ".TABLE_PRINTER_CATEGORY."  where parent_id = '0' AND printer_category_id = '".$filterid."'");
	if(tep_db_num_rows($filterquery)>0) {
       $showfilter = true;
    }
}
if ($showfilter==false){
	//nothing seen in the $_REQUEST so check we have top categories with parent_id==0 and, if so, display
	$filterquery_new = tep_db_query("select * from ".TABLE_PRINTER_CATEGORY."  where parent_id = '0' order by printer_category_id asc limit 1");
	if(tep_db_num_rows($filterquery_new)>0) {
       $showfilter = true;
	   $filterid = 0;
    }
	
}

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_FILTER_PRINTER);
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...