Gossamer Forum
Home : Products : DBMan : Customization :

Simple search on Web page

Quote Reply
Simple search on Web page
I've got dbman set up and running. I want to have a webpage where a user can visit and enter a search term and pull up results. Can I code in the form field links for dbman into a web page I create in an html editor? I don't want all that gray area around everything. I'm sure it's my ignorance of Perl that's driving this question...

------------------
Tim
Quote Reply
Re: Simple search on Web page In reply to
I guess what I'm really wanting is for someone to come to the site and be able to do a search, without having any authorization procedure. I want to put the search field and related selection fields in a left frame. I want lose all the gray field and blue headers from the script.

Am I asking too much?
Quote Reply
Re: Simple search on Web page In reply to
You can get rid of all the gray by editing the html.pl file to have the page look just like you want it to.

But, in answer to your question, yes, you can have a search page in your frame.
You would need to add hidden fields that match the hidden fields in html_view_search:

<form action="[http://url/to/db.cgi]" method="GET">
<input type=hidden name="db" value="[name of your database]">
<input type=hidden name="uid" value="default">

Then add the search field(s). Be sure to match the
name=" "
to the field names you want to search on. You might want to just do a keyword search, in which case your field would be:

<INPUT TYPE="TEXT" NAME="keyword" SIZE=15 MAXLENGTH=255>

Then your submit button would be

<INPUT TYPE="SUBMIT" NAME="view_records" VALUE="[label for the submit button]">

and end off with
</form>

Be sure to fill in the spaces within the square brackets above with information that is appropriate to your site.

You also need to be sure to have $auth_allow_default set to 1 and allow viewing by a default user in your .cfg file.


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

All my advice is offered on the basis of kindness-ware. If I've helped you to solve a problem, go out of your way to be kind to someone today.

Quote Reply
Re: Simple search on Web page In reply to
Howdy!

Thanks for your great reply. The page is at:
www.hyperarts.com/conrad_f.html

A weird bug: The search works if I use the "search" button after entering the keyword. If I use the return key, I get an error message. Can this be fixed?

And I did treat someone nice today, and it felt so good, I'll probably do it again.

Thanks again!





------------------
Tim
Quote Reply
Re: Simple search on Web page In reply to
You can't use multiple keywords right now. Alex is working on that for the next version of DBMan -- if I understood what he said correctly.

As for a select list, just make one with all of the possibilities you want people to be able to search for. You will probably need to set it to a specific field name, although I suppose you could make it a keyword search (using
name="keyword"
for your select list.

----------------
JPD
Quote Reply
Re: Simple search on Web page In reply to
Aw, too bad.

I suppose then that we can't have a multiple select field, eh? How do I target a specific field in my input tags. (Am I being an idiot?)

Thanks so much.

------------------
Tim
Quote Reply
Re: Simple search on Web page In reply to
Well, kindness is really its own reward! Smile

You can make the search work when you use the enter key by adding another hidden field:

<input type=hidden name="view_records" value="1">

(I'm rethinking my sig file since someone thought I was specifically targeting them.)

--------------
JPD
Quote Reply
Re: Simple search on Web page In reply to
Thanks so much. One (perhaps) final question:

How does the user enter multiple keywords to search on? Or, how can I incorporate a select or pulldown in the html page?

Thanks again (and again)



------------------
Tim
Quote Reply
Re: Simple search on Web page In reply to
You can only search for phrases right now, but soon you'll be able to search by keyword as well (someone had posted a mod to do this but I haven't tried it out, it looks close to what I have though).

Cheers,

Alex
Quote Reply
Re: Simple search on Web page In reply to
Maybe I'm being dense here.

I just want to have a select field on my html page. Here's what I flailing around with:

<form action="http://www.hyperarts.com/dbman/db.cgi" method="GET">
<input type=hidden name="db" value="anthony">
<input type=hidden name="uid" value="default">
<input type=hidden name="view_records" value="1">

<P>

<SELECT SIZE="7" NAME="Category">
<OPTION VALUE=1>Pop
<OPTION VALUE=2>Ancient
<OPTION VALUE=3>Abstract
<OPTION VALUE=4>Photo
<OPTION VALUE=5>Renaissance
<OPTION VALUE=6>Impressionist
<OPTION VALUE=7>Expressionist
<OPTION VALUE=8>Modern
</SELECT>
<INPUT TYPE="submit" NAME="view_records" VALUE="Search">

</form>


I've created the select field "Category" in anthony.cfg and it shows up fine when accessing it thru the database interface. I just want to have that on the html page (www.hyperarts.com/conrad_f.html).

Where am I going astray. Thanks, you guys. BTW, we're going to send along the $100 if we utilize this and I'm fairly confident we can.

We need enable the visitor to the site to search by several criteria if possible.

Thanks again.



------------------
Tim
Quote Reply
Re: Simple search on Web page In reply to
Hi Tim,

I think your problem is that you are searching on numbers when you should be searching on the actual text. For instance, you have:

Quote:

<SELECT SIZE="7" NAME="Category">
<OPTION VALUE=1>Pop
<OPTION VALUE=2>Ancient
<OPTION VALUE=3>Abstract
<OPTION VALUE=4>Photo
<OPTION VALUE=5>Renaissance
<OPTION VALUE=6>Impressionist
<OPTION VALUE=7>Expressionist
<OPTION VALUE=8>Modern
</SELECT>

Now unless you actually store the numbers 1 to 8 in the database, that search will fail, because you are looking for a record whose Category = 5 when you should be looking for a record whose category = 'Renaissance'. Replace Value="number" with Value="actual category" and it should work fine!

Cheers,

Alex
Quote Reply
Re: Simple search on Web page In reply to
Ahhh, beautiful, man.

You're so kind.

Okay, the last question, really.

I thought I saw some code here for the same screen to come up (html_view_success) if the search fails (0 matches). Or do I just reconfigure the html_view_failure? I tried putting $in{'view_search'} = 1; before
my ($message) = $_[0]; in the html_view_failure, but this doesn't do it.

My final thanks. Have a great evening.

Tim
Quote Reply
Re: Simple search on Web page In reply to
You could reconfigure html_view_failure or you could change db.cgi.

If you just want to redirect from html_view_failure to html_view_search, what I would do is delete all of html_view_failure and replace it with

&html_view_search

That will send anyone back to the search page if there are no entries.

You can change db.cgi, if you want. Look for sub view records and change the line

&html_view_failure($status);

to

&html_view_search;

I hesitate to change db.cgi unless I really have to, though, because if I want to use it for another database there can be problems.

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