This part is pretty simple. Find your #searchOptions container we set up previously and add in this line:
Now we have a new option to specifically search Zenphoto only.
Notice I've also removed "Search All" since there's no way to consolidate the results from WordPress and Zenphoto without hacking the search results page to pull down both results. That's a little of scope for today's tutorial.
Unlike the previous tutorial, the Zenphoto search won't go through WordPress at all, so we'll need to redirect the search to Zenphoto if that option is clicked.
Here's the heavily commented code I put together to do just that:
So now if we click on "Search Zenphoto Only" it will change the form to search action and method attributes to make it search your Zenphoto install. If we select any of the other options it will switch back to the WordPress settings. It will also modify the input field name since WordPress looks for "s" and Zenphoto looks for "words".
You will need to ensure you change the "action" values to your actual zenphoto and wordpress installs. The Zenphoto action will need "/page/search/" at the end to point to the Zenphoto search page.
More Zenphoto Options
By default Zenphoto includes search options of it's own:
So let's try and incorporate that in to our search box.
First add a new section to your search form:
This code is mostly taken straight from the Zenphoto search form. By default they are all checked, but you can turn them off by removing the checked="checked" attribute.
We'll also add the following to our CSS to indent it a little to make it look like it's supposed to be apart of the ZenPhoto selection above it, and to hide it by default:
Then add the show/hide functions to your jQuery to show the additional options if a user clicks on the Zenphoto Option:
So now if a user clicks on the Zenphoto option, it not only redirects the form, but also shows the Zenphoto tickboxes.
Cleaning Up After Zenphoto
Since WordPress uses get to retrieve the search terms, it's also going to send all of Zenphoto's SEARCH_* inputs to the WordPress search page. We can create a function that checks for a WordPress search and then removes those input fields:
So now if somebody clicks the submit button, the script will check to see if thisOption has the Zenphoto value. If it doesn't, it's obviously a WordPress search, so we'll go ahead and remove those elements from being sent.
So your whole jQuery script should look something like this:
Check out this demo to see it in action, using my old Zenphoto install I still had lying around on my server: