Gossamer Forum
Home : Products : DBMan : Customization :

Putting the Search Terms in the Title??

Quote Reply
Putting the Search Terms in the Title??
Hi,

Anyone have an idea for modifying DBMan to include the search terms in the title and/or the results??

Using this code:
Code:
$html_title: $in{'Month'}

I can insert the name of the Month (or any other db field for that matter) from a preset query. It'll work, but if they search on something other than the month, it returns:
Quote:
There are 1 events for .

Any ideas appreciated.

------------------
farlane aka andrew mcfarlane
www.leelanau.com/pages/farlane/

Quote Reply
Re: Putting the Search Terms in the Title?? In reply to
You can do this a couple of ways. If you only want to print out the search term if the user searched on the Month field, you can say:

Code:
if ($in{'Month'}) {
print "There are $db_total hits for $in{'Month'}";
}
else {
print "There are $db_total hits";
}

If you want to list all fields that were searched on, you'll need to check each field for an $in{'fieldname'} variable and build a string of the search terms.

You might also try a variation on the parse_form subroutine in db.cgi to determine which fields were searched for. I haven't worked out how to do that, but it might be possible.


------------------
JPD





Quote Reply
Re: Putting the Search Terms in the Title?? In reply to
Anyone think of a mod for this?? I would like to have ALL search terms from the the forms to be inserted into the Search Result Form.

Any help in this matter would be most appreciated.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Putting the Search Terms in the Title?? In reply to
In html_view_success, before

&html_print_headers;

add

Code:
foreach $column (@db_cols) {
if ($in{$column}) {
$search_terms .= " $in{$column},";
}
}
chop($search_terms);

Then use

There are $db_total_hits events for $search_terms.

Be sure to have a space between the " and $in{$column},.

------------------
JPD





Quote Reply
Re: Putting the Search Terms in the Title?? In reply to
Thanks, well done! It works great !
Quote Reply
Re: Putting the Search Terms in the Title?? In reply to
Great! I appreciate the codes! Works just fine. JPDeni, you are not only a lady, but a scholar.

One thing though...I have a hidden field known as "Status", which has two variables, which are "Closed" and "Open" in the search forms. I was wondering if there is a way of excluding these variables from being printed in the title??

Thanks.

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Putting the Search Terms in the Title?? In reply to
Code:
if ($in{'keyword'}) {
$search_terms = "$in{'keyword'}";
}
else {
foreach $column (@db_cols) {
unless ($column eq "Status") {
if ($in{$column}) {
$search_terms .= " $in{$column},";
}
}
}
chop($search_terms);
}


------------------
JPD





Quote Reply
Re: Putting the Search Terms in the Title?? In reply to
The code works fine for all the search fields except keyword. If you use a key word search, that code will return multiple instances of the word. For example if I do a keyword search on beach (and these words are in my db) I will get a repetitive list of the word beach, beach, beach etc. for as many words found.

So how can I restrict the routine to eliminate keyword searches.
Quote Reply
Re: Putting the Search Terms in the Title?? In reply to
Code:
if ($in{'keyword'}) {
$search_terms = "$in{'keyword'}";
}
else {
foreach $column (@db_cols) {
if ($in{$column}) {
$search_terms .= " $in{$column},";
}
}
chop($search_terms);
}


------------------
JPD