Webmastersite.net
Register Log In

Search Keyword and/or Category
Search that takes freetext keywords and Category.

Comments on Search Keyword and/or Category

Seelife
Beginner

Usergroup: Customer
Joined: Nov 07, 2011

Total Topics: 1
Total Comments: 7
Seelife
Search Keword and/or category
Posted Nov 07, 2011 - 9:56 AM:

Hi Folks, I appologise if this is covered.
I want to set up a Search that is an AND/OR. I can adapt the present advanced search partly but I dont know the Form commands so well to get what Im after.
Basically its:
Keyword in Title(free text), AND/OR City(free text), AND/OR Country(freetext or selector), AND/OR Category(from list)
I want to allow the user to leave any of the entry fileds Blank. Once I have the logic, I may add or substitute other fields. So, I dont need the dropdowns of Must include, exclude etc.

Can someone suggest a barebones code block that I can mess with.
Thanks & Regards











Seelife
Beginner

Usergroup: Customer
Joined: Nov 07, 2011

Total Topics: 1
Total Comments: 7
Seelife
Posted Nov 07, 2011 - 11:38 AM:

Hi again - This is what I have - but it doesnt work properly :
Thanks.

<div class="center">
<form action="search.php?filled=1&condition={DEFAULTSEARCHTYPE}" method="post">
<input type="hidden" name="whichtype" value="links" >Search for <input type="text" name="search" size="{STANDARDSIZE}" >
<Br>
<input type="text" name="search" size="30">
<select name="country"><option value="links">Country</option><option value="all">search all</option></select>
<BR>
in <select name="incat"><option value="">All Categories</option>{CATOPTIONS}</select>

<button type="submit" class="gobutton"><img src="{IMAGESURL}/search.png" > Search</button></form></div>



Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7867
Paul
Posted Nov 08, 2011 - 1:15 AM:

The keyword is from the title only? In that case scratch what I said before, an advanced search form should be able to do it, will post it shortly.

Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7867
Paul
Posted Nov 08, 2011 - 1:22 AM:

Try this:
<form action="search.php?action=filter&filled=1&whichtype=links" method="post">
Find listings where the title contains any of the keywords
<input type="hidden" name="titlecondition" value="or" >
<input type="text" size="{STANDARDSIZE}" name="titlesearch" >
and the city is
<input type="hidden" name="citycondition" value="=" >
<input type="text" size="{STANDARDSIZE}" name="citysearch" >
and the country is
<input type="hidden" name="countrycondition" value="=" >
<select name="countrysearch"><option value="">all</option>{COUNTRYOPS}</select>
and it's in the category
<select multiple="multiple" name="incatid[]" size="8">{CATOPTIONS}</select>
<input type="submit" value="Search" />
</form>
Seelife
Beginner

Usergroup: Customer
Joined: Nov 07, 2011

Total Topics: 1
Total Comments: 7
Seelife
Posted Nov 08, 2011 - 12:05 PM:

Hi Paul, thank you, this comes very close & I can use it for now.
Ideally it would be great to be an AND/OR as well for the category - that way a user can choose to seach with or without category to get a "site wide" search".
Let me know if this is a custom job.
BTW -Is there a way to "reset" the form?
Regards
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7867
Paul
Posted Nov 09, 2011 - 3:29 AM:

They could just not select any categories to do a sitewide search, or you can add <option value="">all categories</option> in that selector. For a reset button, use <input type="reset" />
Seelife
Beginner

Usergroup: Customer
Joined: Nov 07, 2011

Total Topics: 1
Total Comments: 7
Seelife
Posted Nov 09, 2011 - 3:23 PM:

Hi Paul, Great, thanks for the help, much appreciated.
Regards
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



Sorry, you don't have permission to post posts. Log in, or register if you haven't yet.