Only other thing now that would make it 100% is if someone just selects say defence, i want it to show all the entries without having to write a keyword.
Is that possible Robin? or is that the one thing that is a bit hard!
It comes up with the javascript that you have on that button so I think that is what is throwing it out as the standard EE form handles the submit without any Javascript as far as I know.
Only other thing now that would make it 100% is if someone just selects say defence, i want it to show all the entries without having to write a keyword.
Is that possible Robin? or is that the one thing that is a bit hard!
You could always provide some links on the page to take them to a template which shows the entries based on category?
To do it with just the drop-down is going to take some modifying of code I guess or completely hand-coding a search form as you would need to say “if there is no keyword then just show the category results”. Links would be easier. Is that any good?
The links would work, but they would look a little crude dont you think?
Yes that page is working fine, the other one wasn’t though. I guess you aren’t going to be using the other page though now?
As to the links yes they can look a little crude on their own but with some styling
flashwiz - 11 March 2008 10:12 AM
Just out of curiosity, when you enter a keyword to search is it searching within every custom field that i make searchable?
Actually I don’t think it is in your case as you don’t have the search_in value set anywhere in the form. I could be wrong though.
Yea- a separate list of category links or a hack around
// We only require a keyword if the member name field is blank
if ( ! isset($_GET['mbr']) OR ! is_numeric($_GET['mbr'])) { if ( ! isset($_POST['member_name']) OR $_POST['member_name'] == '') { if ( ! isset($_POST['keywords']) OR $_POST['keywords'] == "") { return $OUT->show_user_error('general', array($LANG->line('search_no_keywords'))); } } }
That’s needed if no keywords. Or you might could have js put in a * for the keywords if it’s empty- then make sure min_length is set to 1. Think that’s what I did.
And as to where is seaches- it’s determined by search_in- if set to everywhere, it hits the title and all searchable fields.
Hi Robin, silly question, but where does that code go in order to hack it?
Or where and how do i put the other bit so that i can set the keyword to min length 1 and get javascript to add in the *. Sorry my coding only goes sooooooo far
I think the code that Robin has shown there is the code that currently resides in admin->modules->search->mod.search.php at around line 140. I think that you would need to do a modification to it to enable you to get what you need.
As to the javascript side of things my Javascript is not very good so I had to go away and code this and test it out but this kind of thing should work for you hopefully.
If they don’t click into the field then it already has the field value=”*” value set to a * so will just work. You will of course need to set the minimum search length to 1 as Robin said but the code above should cover all the bases. Perhaps just copy-paste the whole of the code I have given into a new blank template and see what it does. Should be fairly easy to take apart to get what you need from it then.
Well this is all working nicely now… apart from one thing… do you have to turn on pagination somewhere within search results? Never had a problem before, but for some reason or other it doesnt work when i do a search now.