Gossamer Forum
Home : Products : DBMan : Installation :

Can Sort By options be limited?

Quote Reply
Can Sort By options be limited?
My database has a lot of fields that don't make sense as sort fields (description, directions, address, etc.). How can I adjust the Sort By options on the Search screen so that only the relevant fields, such as price or ID are shown?

Thanks in advance.
Quote Reply
Re: [smithT] Can Sort By options be limited? In reply to
You can modify sub html_search_options to only show certain fields to users.

For Example:

sub html_search_options {
# --------------------------------------------------------
# Search options to be displayed at the bottom of search forms.

print qq~
<P><INPUT TYPE=HIDDEN NAME="Validated" VALUE="Yes">
<CENTER> <$font><STRONG>Search Options:</STRONG> <P>
<INPUT TYPE="CHECKBOX" NAME="ma"> Match Any
<INPUT TYPE="CHECKBOX" NAME="cs"> Match Case
<INPUT TYPE="CHECKBOX" NAME="ww"> Whole Words
<INPUT TYPE="CHECKBOX" NAME="re"> Reg. Expression<P>
Keyword Search</font> <FONT SIZE=-1> (will match against all fields)</FONT><BR>
<INPUT TYPE="TEXT" NAME="keyword" SIZE=30 MAXLENGTH=255><P>
<$font> Return records <INPUT TYPE="radio" NAME="mh" VALUE="$db_max_hits" CHECKED><B>in a list</B> or <INPUT TYPE="radio" NAME="mh" VALUE="1"><B>one record at a time</B>. </font>
<P>
<table border=0 width=470>
<TR><TD><$font>Sort By:</font></TD><TD><$font>Sort Order:</font></TD><TD><$font>Max. Returned Hits</font></TD></TR>
<tr valign=top><TD><select name="sb" size="1">
<option>Select from list
<option value="Category">Topic
<option value="Title">Title
<option value="Author">Author
<option value="Date">Date</select></td>
<TD><SELECT NAME="so">
<OPTION SELECTED VALUE="ascend">Ascending<OPTION VALUE="descend">Descending</SELECT></TD><TD><INPUT TYPE="TEXT" NAME="mh" VALUE="$db_max_hits" SIZE=3 MAXLENGTH=3></TD></tr></table></CENTER><br>
<$font><strong>Search Tips:</strong><br>&nbsp;&nbsp;&nbsp;&nbsp;- use '*' to match everything in a field)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;- put a '&gt;' or '&lt;' at the beginning to to do range searches.<BR></font>
~;
}

There are also other ideas in the FAQ noted below under "Searching"

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Can Sort By options be limited? In reply to
Okay, thanks. That's exactly what I needed.
Quote Reply
Something I found out In reply to
Using the '<option value="Price"> Price' didn't work when I put it into my HTML.PL file, so after much head-scratching, I finally figured out that the cgi script wasn't looking at field names, but their offset numbers as defined in the config file.

I changed it to '<option="5">Price' (where 5 was the number of the price field) and it worked fine.

Just a note to anyone who wants to do this type of selective sort by processing.
Quote Reply
Re: [LoisC] Can Sort By options be limited? In reply to
Hi! I was wondering about a similar problem... What I was wondering is if my database is not set to autogenerate and I do not want admin fields to be shown in the sort option for registered users but still show it to admin how can I do it other than hardcoding it as suggested?
Julian