Support Forums

Sorting listing

This is a discussion on Sorting listing within the Technical Support forums, part of the Technical Support Forums category; We can setup the 'Initial Listings Sort' of the ads list in the Search Listing setup (strange idea to put ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

This topic is resolved.

If you have a similar issue that this thread does not address, open a new related support topic.

 
Thread Tools Display Modes
Old 04-16-2008, 08:33 AM   #1
Senior Member
 
 
Join Date: Apr 2008
Posts: 140
Rep Power: 10
philoo is on a distinguished road
Default Sorting listing

We can setup the 'Initial Listings Sort' of the ads list in the Search Listing setup (strange idea to put this there).

The problem I have is that if I setup 'Initial Listings Sort' to show first the featured ads, the other ads (that are not featuredm) are sorted descending by their creation date or their database ID. In the result, new ads are systematically at the end of the listings and the older ones at the beginning.

It could be interested to introduce a second sort key, to show (by example) :

- first Featured ads
- second newest ads

philoo is offline  
Old 04-16-2008, 09:36 AM   #2
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,319
Rep Power: 125
Eric Barnes is a jewel in the rough
Default

Before v4 the user was not allowed to resort so this was left to initially sort the listings. Keep in mind after the listings have been sorted a cookie is stored and it will always go back to the last sort choosen.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 04-16-2008, 11:02 AM   #3
Senior Member
 
 
Join Date: Apr 2008
Posts: 140
Rep Power: 10
philoo is on a distinguished road
Default

Eric,

I am not convinced by this story of cookie, but that's not the main problem.

If I choose to sort initialy by "Featured", the non featured ads are sorted as the oldest one at the top of the list (below the featured ones), the newest at the bottom.

Imagine, I have 5 featured ads at the top and around 50 non-featured ads in the list. The customers will never see the recent ads that are 3 or 5 five pages later !!!! Nobody can decently choose that !

I would like to know if there is a way to introduce a second sorting condition, may be altering the SQL request...
philoo is offline  
Old 04-16-2008, 11:11 AM   #4
Coder
 
Join Date: Mar 2006
Posts: 4,997
Rep Power: 121
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by philoo
I would like to know if there is a way to introduce a second sorting condition, may be altering the SQL request...
If you have the developer version you could alter the query manually.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 04-16-2008, 11:21 AM   #5
Senior Member
 
 
Join Date: Apr 2008
Posts: 140
Rep Power: 10
philoo is on a distinguished road
Default

I have designer version ...

... any help to locate the query ?
philoo is offline  
Old 04-16-2008, 11:39 AM   #6
Coder
 
Join Date: Mar 2006
Posts: 4,997
Rep Power: 121
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by philoo
I have designer version ...

... any help to locate the query ?
My applogies, I miss spoke above, you need the developer version to access the php code to alter the query.

[edit: Looks like you miss spoke again. ]
[edit: Nope- I corrected my above post so it just looks like I miss spoke again. ]
__________________
Larry

Knowledge learned is more valuable than knowledge given.

Last edited by Eric Barnes; 04-16-2008 at 12:13 PM.
Lhotch is offline  
Old 04-16-2008, 12:49 PM   #7
Senior Member
 
 
Join Date: Apr 2008
Posts: 140
Rep Power: 10
philoo is on a distinguished road
Default

i am so stupid, I have the developer version
philoo is offline  
Old 04-16-2008, 12:55 PM   #8
cwp
Senior Member
 
cwp's Avatar
 
Join Date: Jun 2007
Posts: 296
Rep Power: 18
cwp is a jewel in the rough
Default

Quote:
Originally Posted by philoo
Eric,

I am not convinced by this story of cookie, but that's not the main problem.

If I choose to sort initialy by "Featured", the non featured ads are sorted as the oldest one at the top of the list (below the featured ones), the newest at the bottom.

Imagine, I have 5 featured ads at the top and around 50 non-featured ads in the list. The customers will never see the recent ads that are 3 or 5 five pages later !!!! Nobody can decently choose that !

I would like to know if there is a way to introduce a second sorting condition, may be altering the SQL request...
I understand where you're coming from.. It would be nice to have a few more options for the "initial listings sort". Like a check box that says "Featured listings always on top of other listings?"

And then take the "Featured Listings" out of the first drop down box.

Something like this would solve philoo's problem.. and mine.
__________________
Version 4.0.3 Developer
cwp is offline  
Old 04-16-2008, 01:02 PM   #9
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,319
Rep Power: 125
Eric Barnes is a jewel in the rough
Default

That should be pretty easy. Open includes/classes/kernel/Listings.php and go to line 360:
Code:
$listingSQL=$sSQL .' '. $where .' ORDER BY '. $sqlsort .' '. $sortorder;
Change to something like:
Code:
$listingSQL=$sSQL .' '. $where .' ORDER BY featured DESC, '. $sqlsort .' '. $sortorder;
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 04-16-2008, 01:04 PM   #10
Coder
 
Join Date: Mar 2006
Posts: 4,997
Rep Power: 121
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by philoo
i am so stupid, I have the developer version
If you point a browser to a categoyon your site where there are ads and then add debug=1 to the URL (using a ? or & depending on if there are any existing variables on the URL already) it should cause the debug comsole to pop up. This will show you the script in use and where you would want to start your search for the query.

Most likely this will be the category.php file. If we look through the code we can see there is a section which is processed if the category is set not to display ads and another section to process if the category is suppose to display ads, thats the section we are interested in and looks like this....


Code:
if($showlistings=="Y")
  {
	$settings=$Core->getSearchSettings();
	$pageNum = 1;
	$options['sortfield']=MAIN_PRODUCT_SORT;
	$options['sortorder']=MAIN_PRODUCT_SORT_OPTION;
	if(isset($_GET['page']))
	{
		$pageNum = (int)$_GET['page'];
	}
	$options['section']=$sec;
	$list=$Listings->getAllListings($options, $pageNum, MAX_ROWS_SEARCH);
	$class_tpl->assign('results', $list["list"]);
	$class_tpl->assign('sqlsort', $list["info"]["sqlsort"]);
	$class_tpl->assign('sortorder', $list["info"]["sortorder"]);
	$class_tpl->assign('oppositesort',  $list["info"]["oppositesort"]);	
	$class_tpl->assign('showlistings', 'Y');
	$class_tpl->assign('file', 'category.php');
}
There is no actual query here but a couple lines catch my attention......

$options['sortfield']=MAIN_PRODUCT_SORT;
$options['sortorder']=MAIN_PRODUCT_SORT_OPTION;

and

$list=$Listings->getAllListings($options, $pageNum, MAX_ROWS_SEARCH);

We may be able to hard code additional options in here to be included in the call to the function getAllListings, but I would have to experiment. The above does show us however that the query itself is being done by the function getAllListings which is located in /include/classes/kernel/listings.php

I dont have time to look into it deeper at the moment, ned to head out for a meeting. But that should get you started.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
MODIFICATION: Receive a copy of the email sent from visitors to listing owners. cwp Modules / Plugins / Modifications 15 07-25-2009 08:02 AM
Passing Listing ID to notification emails abkeller v3.1 Questions & Support 6 08-07-2007 11:20 PM
New Listing Notify Not working for memberships abkeller v3.1 Questions & Support 0 08-03-2007 03:51 AM
User: See's Membership listing package garysr v3.1 Questions & Support 23 11-04-2006 02:08 PM


All times are GMT -4. The time now is 08:56 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0