Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Problems with drop downs in product listing pages


Guest

Recommended Posts

Hi, new member here. I've been running a website for a few months and have used these forums for quite a while but this is the first time I've not been able to find help that someone hasn't already asked for. I hope someone will be able to help. I'm still a php beginner, but know a little bit however can't work this out.

 

Yesterday I set up a couple of drop downs on my product listing category pages. I want to use one for sorting the products (A-Z ascending and descending, and by price), and the other one to give the user a choice on how many products to display on the screen.

When they are used I can see that they add variables onto the url, one adds ?sort=xx and the other adds ?display=xx (which I have added some code to the product_listing.php page to change the MAX_DISPLAY_SEARCH_RESULTS depending on what is in the url). The problem I'm having is that I can't make them work together as if you use one drop down and then use the other it resets the variable in the url. So you can't sort by price AND then choose to display however many products you want on the screen. I'm sure it's simple but I don't have the knowledge to do this. Here's the code if that helps:

 

 

 

// BOF: Show ALL Products Button

if($HTTP_GET_VARS['display'] == 'All') {

define('MAX_DISPLAY_RESULTS', 200);

} elseif ($HTTP_GET_VARS['display'] == '9') {

define('MAX_DISPLAY_RESULTS', 9);

} elseif ($HTTP_GET_VARS['display'] == '15') {

define('MAX_DISPLAY_RESULTS', 15);

} elseif ($HTTP_GET_VARS['display'] == '21') {

define('MAX_DISPLAY_RESULTS', 21);

} else {

define('MAX_DISPLAY_RESULTS', MAX_DISPLAY_SEARCH_RESULTS);

}

 

$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_RESULTS, 'p.products_id');

// EOF: Show ALL Products Button

 

if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>

<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>

</tr>

</table>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td width="150"></td>

<?php

 

// Additional Products Sort

 

 

echo '<td align="right" class="main">' . tep_draw_form('sort', FILENAME_DEFAULT, 'get') . 'Sort by: ';

 

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);

} else {

echo tep_draw_hidden_field('cPath', $cPath);

}

 

$sort_list = array( '2a' => 'Products Name A to Z',

'2d' => 'Products Name Z to A',

'3a' => 'Price Low to High',

'3d' => 'Price High to Low');

foreach($sort_list as $id=>$text) {

$sort_range[] = array('id' => $id, 'text' => $text);

}

 

echo tep_draw_pull_down_menu('sort', $sort_range, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onchange="this.form.submit()"');

echo tep_draw_hidden_field('filter_id', (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''));

echo '</form></td>' . "\n";

 

 

// End Additional Products Sort

 

 

// Results per page

 

 

echo '<td align="right" class="smallText">' . tep_draw_form('display', FILENAME_DEFAULT, 'get') . 'Results per page: ';

 

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);

} else {

echo tep_draw_hidden_field('cPath', $cPath);

}

 

$display_list = array('9' => '9',

'15' => '15',

'21' => '21',

'All' => 'All');

foreach($display_list as $id=>$text) {

$display_range[] = array('id' => $id, 'text' => $text);

}

 

echo tep_draw_pull_down_menu('display', $display_range, (isset($HTTP_GET_VARS['display']) ? $HTTP_GET_VARS['display'] : ''), 'onchange="this.form.submit()"');

echo tep_draw_hidden_field('filter_id', (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''));

echo '</form></td>' . "\n";

 

// Results per page

 

 

Basically I need it to retain the url and then add to it if the other drop down is used. Is there anyone out there who might be able to help?

 

Thanks in advance.

Andrew.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...