Multi-Field Search Syntax?

10 posts by 3 authors in: Forums > CMS Builder
Last Post: February 13, 2009   (RSS)

By DHester - January 19, 2008 - edited: January 19, 2008

I've been experimenting with the new search parameters in CMS Builder. I can search for any single field and get matching records using this:

<h5>Keyword Search:</h5>
<form method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<input type="text" name="title_keyword" value="" size="15">
<input type="submit" name="" value="Search">
</form>



In the example above I'm searching the "Title" field. Ideally I'd like to search both my "title" and "content" fields. I can't figure out how to query 2 fields with one search? Can someone point me in the right direction?

Thanks!
Darren Hester
www.designsbydarren.com

Re: [DHester] Multi-Field Search Syntax?

By Dave - January 19, 2008

Hi Darren,

Just list them one after another with the search type on the end. Like this: title,content_keyword

Let me know if that does the trick.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Multi-Field Search Syntax?

By DHester - January 20, 2008

Thanks, that did the trick! I'm really enjoying CMSB. You did a great job. I've used a lot of other content management/blogging scripts including snews, wordpress, and expression engine. CMSB is quickly becoming my favorite [;)]

I appreciate all your help!
Darren Hester
www.designsbydarren.com

Re: [Dave] Multi-Field Search Syntax?

By studio-a - December 6, 2008 - edited: December 8, 2008

Hi,

I have created a quick search feature from a web form drop menu, see code below. Base on the information within the help section (http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html), we can search more than one field.

My Question: Can we combine a search with more than one field WITH a search condition? My search results are not accurate when I try to search with both requests.

<select name="dress_price" onChange="MM_jumpMenu('self',this,1)">
<option value="#" selected>Search By Price:</option>
<option value="myDomain/ListingsWeddings.php?salePrice,price_max=1000">$50 to $999</option>
<option value="myDomain/ListingsWeddings.php?salePrice,price_min=999&salePrice,price_max=3000">$1,000 to $2,999</option>
<option value="myDomain/ListingsWeddings.php?salePrice,price_min=2999">$3,000 and Above</option>
</select>


My results have no error messages. HOWEVER, some of the results display records that do not match the price minimum and maximum search. The “price” field and “salePrice” field are text boxes within the CMS. I changed the sale_price field to salePrice in case the underscore was creating a problem, still finding inaccurate results.

Let me know if decimals within the text field would cause complications. I have tested it with and without decimals, still no errors messages yet inaccurate results. [unsure] Again, the only time an accurate result is found is when I do NOT search with a combination and condition request. Unfortunately, both fields are required for the search to be useful.

[font "Verdana"]One thing I did notice, if I want to create a search for items with a price of $999.00 or lower I needed to set the maximum number within the search to be 1000 (one number above). I would have thought the maximum amount would be included and stop at that amount. Instead I needed to go one digit higher (or lower which ever the case may be). Please let us know if this is true.

I look forward to your help in solving my search problem.
Thanks,

Re: [studio-a] Multi-Field Search Syntax?

By Dave - December 8, 2008

Hi Studio-a,

I want to do a little more research on this one. I'll get back to you shortly. Stay tuned. :)
Dave Edis - Senior Developer
interactivetools.com

Re: [studio-a] Multi-Field Search Syntax?

By Dave - December 9, 2008

Hi Studio-a,

Thanks for your patience.

>I would have thought the maximum amount would be
>included and stop at that amount.

I wasn't able to recreate this issue locally. If you have price_max=999 that should include records with a price of 999.

You can combine fields with a search but you'll get an "OR" search. So for example this: salePrice,price_max=1000 will essentially perform this query: (`salePrice`<= '999' OR `price`<= '999')

So if either salePrice or price is less than 999 it will return the record.

The other thing to watch for is that you only have numeric values in your prices (numbers and decimal ("."), no commas or dollar signs) or you won't get accurate results. You can restrict what characters are allowed in a field in the field editor.

If you're still getting strange results feel free to email me CMS and FTP login details (email, don't post in the forum) and I can take a look for you.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Multi-Field Search Syntax?

Hi Dave,

I am still having complications with the minimum search syntax. I emailed support@interactivetools.com with your name in the subject line. I look forward to your reply!

Thanks

Re: [studio-a] Multi-Field Search Syntax?

By Dave - January 22, 2009

Hi studio-a,

Feel free to email me the ticket number to dave@interactivetools.com and I can take a closer look.
Dave Edis - Senior Developer
interactivetools.com

Re: [studio-a] Multi-Field Search Syntax?

By Dave - February 13, 2009

Glad to hear you got it working! Thanks for posting back with your working code! :)
Dave Edis - Senior Developer
interactivetools.com