Gossamer Forum
Home : Products : DBMan : Customization :

Sort by different fields from a select box

Quote Reply
Sort by different fields from a select box
I am trying to have search results sorted by different fields according to which field is selected from a select box.

I have set up the following:
Field 1 = Category 1
Field 2 = Category 2
Field 3 = Category 3
Field 4 = Sort code for Category 1
Field 5 = Sort code for Category 2
Field 6 = Sort code for Category 3

The select box shows Category 1,2, and 3. I want the search results for Category 1 to be sorted by Field 4, the search results for Category 2 to be sorted by Field 5, and the search results for Category 3 to be sorted by Field 6.

Is this possible with an IF-ELSE statement in sub html_view_search?

Many thanks!
Quote Reply
Re: [rdavis] Sort by different fields from a select box In reply to
do the three sort fields contain data for all the categories? what i mean is, if a record has been assigned category 1, could it have data in all three of the sort fields? if not, you could have one category field and one sort field. then if you're searching for category 1, you would sort by the only sort field and get the results you want. hope this makes sense.

if you have data in all three sort fields and thus need the three separate fields, i think you would have to put your if...then statement in sub query if you are viewing records from multiple categories.

without examples, it's hard to answer. i usually have just one category field. the different values in that field are how i distinguish the category.

Last edited by:

delicia: Dec 29, 2009, 7:39 AM
Quote Reply
Re: [delicia] Sort by different fields from a select box In reply to
Thank you, Delicia. I will try what you suggest and let you know how it works out.

BTW, by any chance do you do custom installations? I need to hire someone to install the password lookup mod (http://jpdeni.com/dbman/Mods/secure_lookup.html) and the File Uploading mod (http://jpdeni.com/dbman/Mods/file-upload3.txt)

Rick
Quote Reply
Re: [rdavis] Sort by different fields from a select box In reply to
sorry but i don't do installations. good luck and let me know how it works out. if you don't already have it, you'll probably want the mod or hack to sort by multiple fields.