Member
Member
quiraang   2009-06-27, 09:51
#1

I am not using the printSearchForm()function, instead I have a custom search form which replicates the basic zenphoto search form plus I have added a series of checkboxes for common tag values.

I am searching on titles and partial tags only.

The form has an onSubmit event which fires a javascript which concatenates the contents of the input textbox id="search_input with the values of the checkboxes which I get using MooTools functions.
I then set the search input textbox to this new string and submit the forming using sf.submit, where sf is the form object.

However my search string is getting truncated somewhere along the line. If I type tree in the search box and check photo I generate the search string treeANDphoto. The search seems to lose my constructed string and only operates with what's in the inputbox ie tree.

Perhaps I'm being too clever for my own good when I guess I don't really understand the subtleties of how search works. Can you give me some advice and perhaps point me at some documentation about how search works. I've scanned the class-search code, and it's a bit above my level of PHP expertise - should I be using the setSearchParams function directly ...?

Member
Member
quiraang   2009-06-27, 11:11
#2

Meant to say I'm using v1.2.5

Member
Member
sbillard   2009-06-27, 16:51
#3

It would sound like your custom code is not submitting the full search string that you desire. The search engine will parse the $_REQUEST['words'] parameter for the search search criteria. This is what you have to populate with your javascript onSubmit.

For more details look at the class-search instantiation function.

Member
Member
quiraang   2009-06-27, 22:00
#4

I seem to be submitting the search string. If I echo $_POST['words'] I see the full search string tree&photo but when I echo $_REQUEST['words'] I get just tree

Member
Member
sbillard   2009-06-28, 01:03
#5

Interesting. Those two should be the same. Of course, I do not know what the JS interaction might be doing. Anyway, you need to get the $_REQUEST['words'] bit correct as that is what the search engine looks at. One way to do that would be to add it to the query parameter string.

Member
Member
sbillard   2009-06-28, 01:10
#6

Had another thought. Perhpas it is the '&' character that is causing you the trouble. Have you tried using AND instead? Remember, ofthe & is used as a separator on WEB URLs. In those cases you have to use the HTML entity & in its place. This is different for POST methods from GET methods. Perhaps the Javascript is not properly dealing with this.

Member
Member
quiraang   2009-06-28, 05:08
#7

I did a print_r on both of the $_POST and $_REQUEST arrays and the answer was obvious.

It was my bad.

I use document.cookies to persist the form settings and the one that held the value of the search box was called words too. I had forgotten that $_REQUEST retrieves $_GET and cookie values too and $_REQUEST was picking up the cookie.

Thanks for your time and apologies for my stupidity!

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.