Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Adding Dropdown Sorter to Category Listing and Search Results

Adding Dropdown Sorter to Category Listing and Search Results

Locked

Views: 1,816

Results 1 to 1 of 1
This thread is locked. New replies are disabled.
15 Oct 2008, 1:26 AM
#1
preacherman avatar

preacherman

New Zenner

Join Date:
Oct 2007
Posts:
7
Plugin Contributions:
0

Adding Dropdown Sorter to Category Listing and Search Results

HELP!

I think I've figured out my problem. I JUST DON'T KNOW HOW TO FIX IT! :blink:

I've added a drop down sorter to the Category Listing(tpl_index_product_list.php) and the Advanced Search Results Page(tpl_advanced_search_result_default.php).

When I make a selection in the drop down sorter, it seems to work... it produces the correct URL and changes the "select" in the drop down sorter, HOWEVER, it doesn't sort the products listed (they keep the same sort order).

I THINK the problem can be fixed by changing this piece of code that is found in BOTH the default_filter.php (that controls the sort order for the Category Listing) AND in the header_php.php (that controls the sort order for the Advanced Search Page)...

// set the default sort order setting from the Admin when not defined by customer 
  if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') { 
    $_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER; 
  } 

  if (isset($column_list)) { 
    if ((!isset($_GET['sort'])) || (isset($_GET['sort']) && !ereg('[1-8][ad]', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) { 
      for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { 
        if (isset($column_list[$i]) && $column_list[$i] == 'PRODUCT_LIST_NAME') { 
          $_GET['sort'] = $i+1 . 'a'; 
          $listing_sql .= " order by p.products_sort_order, pd.products_name"; 
          break; 
        } else { 
// sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER is left blank 
// for reverse, descending order use: 
//       $listing_sql .= " order by p.products_sort_order desc, pd.products_name"; 
          $listing_sql .= " order by p.products_sort_order, pd.products_name"; 
          break; 
        } 
      } 
// if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off 
      if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') { 
        $_GET['sort'] = '20a';  

And more specifily, this line of code:

$listing_sql .= " order by p.products_sort_order, pd.products_name";  

The sort ALWAYS reverts back to what is listed in this code for some reason. I've tried several ways to just remove it, but I always get an error. :frusty:

Is there a way that this code can be adjusted so that the sort order doesn't default to what is listed in that code?