Advanced searching

Hi all and Happy New Year


Are there anyone who has implemented a search with Matrix that allows you to tick boxes of pre-defined search terms? Is this possible?



To clarify it could be something like this:

  • a simple keyword search field
  • some tick boxes with pre-defined search keywords such as milk, recipe, cow and eggs



    The intention is that the user can tick the suggested keyword box so that it is included within the search.



    Any ideas?





    Look forward to hear the public reply :slight_smile:




  • Karl

You can do this, but you'd have to hard-code those words (or use an asset listing to generate the list from assets) and then use JS to populate a hidden var in the form.


Basically, it is possible and I have seen it done on a system I was working on, but it really means writing a custom frontend for the search engine.



(unless anyone has a better idea)

Thanks Greg. I was afraid that would be the solution.


Will the code be something like this then? :

    


... of course within the form contents that is already there!


Thanks again for your help.

Karl

It would be interesting to see if you can do this with just HTML: Create a textbox question on a search page, but don't use its keyword to print the input box. Rather, use HTML and checkboxes instead, with the same ID/value. Then, by selecting multiple values, it should just pass the correct stuff to the search engine.

Cheers Avi,


Will give it a go tomorrow.



Where in Aus are you guys stationed? (looking at the time of posting I assume you are down there) :wink:



Karl

[quote]Where in Aus are you guys stationed? (looking at the time of posting I assume you are down there)  :wink:
[right][post=“13840”]<{POST_SNAPBACK}>[/post][/right][/quote]



Heh. Squiz has offices in Sydney, Canberra, Melbourne, Hobart and Wellington (in NZ). I’m based in the Melbourne office, while Greg (and the rest of the developers) are in Sydney.

Cool,


The problem is that when you submit more than one option from the checkboxes OR have the keyword present, you will not be presented with the information. Here is the code that is generated


    queries_search_query=bread&queries_search_query=milk&queries_search_query=
    This returns no results...
    
    queries_search_query=bread&queries_search_query=milk
    This returns result based on the milk option... (but not a combination of bread as well


Any ideas what could be done to work around this?

It won't be too much of a problem not having the keyword search option enabled. This can be solved in different ways.

Look forward hearing back.

[quote]Any ideas what could be done to work around this?
[right][post=“13849”]<{POST_SNAPBACK}>[/post][/right][/quote]



Interesting. One of the developers would have to look at the code to see why the values aren’t being parsed the way you’d want. It may have to be submitted as a feature request, or done with JavaScript as Greg suggested.

Thanks Avi for your feedback. I have found a solution where I have created a couple of search fields that I use to pass on the selected values from the radio buttons. I did consider tickboxes before but have found that radio buttons can do the job for the moment.


It then limits the search by just passing one parameter but that is fine with this project. However I would like to know how one can pass more than one parameter using one variable, i.e. passing values from two checkboxes as search string. If anyone has any ideas I am all ears.



Thanks for all assistance so far.



Cheers,

Karl

You want to add square brackets so the query looks like this

    queries_search_query[]=bread&queries_search_query[]=milk&queries_search_query[]=

This will submit ALL values to the search page. Now, whether search page can use it is not known.



Other than that, combining many input elements into one query variable doesn't look possible without JavaScript.

Hi Andrei,


That piece of code (array) did miracles to the search so thank you very much for that. Don't know why I didn't think of that :slight_smile:



Thanks for all help