Start a new topic
Answered

Sort by newest member

Is it possible to Sort the search results by Newest - Oldest members as default?




Best Answer

Hi JJ (May I call you JJ?), There are several ways of doing this, but you can use this example which is the most easiest and basic I can provide:


1. Go to your Widget Manager and look for the Showing - Sort By Header Widget


2. Customize and Edit this Widget and go to line 20 where something along the lines of this should be shown:

 

     <option value="name ASC" <? if (strstr($_COOKIE[sort],"name ASC")) { ?>selected<? } ?>>Name A-Z</option>
     <option value="name DESC" <? if (strstr($_COOKIE[sort],"name DESC")) { ?>selected<? } ?>>Name Z-A</option>

 

3. Add the following 2 lines beneath it:

 

     <option value="user_id ASC" <? if (strstr($_COOKIE[sort],"user_id ASC")) { ?>selected<? } ?>>Oldest</option>
     <option value="user_id DESC" <? if (strstr($_COOKIE[sort],"user_id DESC")) { ?>selected<? } ?>>Newest</option>

 

4. This should give you the final result:

 

Please verify and let me know if it worked as you wanted.



Answer

Hi JJ (May I call you JJ?), There are several ways of doing this, but you can use this example which is the most easiest and basic I can provide:


1. Go to your Widget Manager and look for the Showing - Sort By Header Widget


2. Customize and Edit this Widget and go to line 20 where something along the lines of this should be shown:

 

     <option value="name ASC" <? if (strstr($_COOKIE[sort],"name ASC")) { ?>selected<? } ?>>Name A-Z</option>
     <option value="name DESC" <? if (strstr($_COOKIE[sort],"name DESC")) { ?>selected<? } ?>>Name Z-A</option>

 

3. Add the following 2 lines beneath it:

 

     <option value="user_id ASC" <? if (strstr($_COOKIE[sort],"user_id ASC")) { ?>selected<? } ?>>Oldest</option>
     <option value="user_id DESC" <? if (strstr($_COOKIE[sort],"user_id DESC")) { ?>selected<? } ?>>Newest</option>

 

4. This should give you the final result:

 

Please verify and let me know if it worked as you wanted.


Thanks Luis, it worked, however is it possible that the Featured Listings can still come before the newest to oldest list?


In other words, I want the Featured members to always be placed above regular members


Hope that makes sense and it is possible

Yes, it can be done, but I would need another site from you in order to test that out and give you a concrete solution. If you have a site that has a lot of members, that can help me a lot.

Hi Luis, we dont have lots of members but we have a live site with 7 members.

We are not allowed to post the URL on here, how can I pass the info to you?

 

Hi JJ, please send the information to luis@brilliantdirectories.com and I'll work on it. Thanks bud.

The owner of the site has emailed you

 

Hi JJ, I have made the change by doing the following, to the change I mentioned above, append the following users_data.subscription_id DESC so it looks something like this:
 

 

<option value="users_data.subscription_id DESC, user_id DESC"     <? if (strstr($_COOKIE[sort],"users_data.subscription_id DESC, user_id DESC")) ...

 

 This way you will get the Featured Listing first (Please for the love of Pizza correct me if am wrong). let me know if this is the answer you were looking for.

Hi Luis,

The drop down works great however we need the order "most recent" to be the default order when someone searches

How can we do that?

 

Hi JJ, see the word in the code that says DESC, this is a descending order and can be changed for ASC (Ascending order). So for example in the last code I provided, if you wanted to show the opposite, it would look like this:

 

<option value="users_data.subscription_id ASC, user_id ASC"     <? if (strstr($_COOKIE[sort],"users_data.subscription_id ASC, user_id ASC")) ...

 

And like always friend, let me know if this is what you meant with most recent.