webspace Posted February 27, 2003 Share Posted February 27, 2003 Hi everyone, I'm banging my head against the wall on this one... I would like products to be sorted by model as the default action. Currently products are sorted by name as the default action. I've attempted to modify $listing_sql .= ' order by '; to $listing_sql .= ' order by p.products_model'; at around line 200 of default.php. I've commented out the switch section below it as well. Still, products are sorted by name. If anyone has an answer or can point me at a post that discusses this, I'd be grateful. At present I've searched through this forum and the OSCdox forum w/o much luck. Thanks, Matthew Hellinger Link to comment Share on other sites More sharing options...
medisave Posted February 27, 2003 Share Posted February 27, 2003 You need to look at the top of default.php Heres what I have roughly at the top: <?php /* $Id: default.php,v 1.78 2002/10/27 20:36:21 dgw_ Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2002 osCommerce Released under the GNU General Public License */ if ( !$HTTP_GET_VARS['sort'] ) { $HTTP_GET_VARS['sort'] = '3a'; $sort_order='d'; } require('includes/application_top.php'); You need to change the line VARS['sort'] = '3a'; to what ever you want it sorted by - the way to do this is hover over the sort option in the listing on your website to find it - it probably is 1a though if you want to sort by model. Hope this helps Cheers.. Graham Wright ________________ Link to comment Share on other sites More sharing options...
webspace Posted February 27, 2003 Author Share Posted February 27, 2003 Thanks Graham, thanks for the tip. Although the version of default.php doesn't have the exact same placement of this statement, I did a search for !$HTTP_GET_VARS['sort'] and found the following at around lines 194-204: if ( (!$HTTP_GET_VARS['sort']) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'],0,1) > sizeof($column_list)) ) { for ($col=0; $col<sizeof($column_list); $col++) { if ($column_list[$col] == 'PRODUCT_LIST_NAME') { $HTTP_GET_VARS['sort'] = $col+1 . 'a'; $listing_sql .= " order by pd.products_name"; break; } } } else { I changed two lines to the following: $HTTP_GET_VARS['sort'] = 1 . 'a'; $listing_sql .= " order by p.products_model"; The first change is responsible for moving the '+' next to 'Model' and the second change is responsible for setting the default query to order by model #. Hope others might find this useful Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.