18

My client asked me for a single field, that would work 2 ways:

  • Autocomplete filter based on taxonomy.
  • If site visitor inputs something that's not in taxonomy, full text search should be performed on content's body, and appropriate info message shown.

That way if user enters category name, he will get hand picked nodes listed, and if anything else, he will at least get some content.

Separately, it's easy. But how to combine these behaviours in one field?

  • 1
    Separately it's easy, which module you work with to have auto complete based on taxonomy ? For me the trick will be a small javascript code that will check if there is no result change the submit button action so it will redirect to /search/yourkeywordsearch – sel_space Jun 8 '13 at 12:10
17
+100

Finder module will do your requirement exactly, You can select taxonomy term as well as node title, body, fields, ..etc to perform the search.

There are many ways to put together finder's functionality to get the sort of search form you need. There are also many hooks and theme functions allowing full customization of finder's output.

It is used for these purposes:

As a search tool to find a group of nodes or users.
As a way to navigate to a specific node or user page that matches criteria.
As an alternative to exposed filters for a Views module display.

See the below screen shot, In the finder field you can choose taxonomy terms as well as node body to perform the search in auto-complete exposed field, even you can perform multiple keyword search separated by comma. Read the Finder documentation for more information..

enter image description here

Once you added the element you can select the finder fields from the list, hold the

Ctrl key to select the taxonomy term as well as Node: Body

  • It's a bit old and needs co-maintainers, but looks like it fills all my needs. Will need to test it, but so far it seems to be the perfect answer for my use case. – Mołot Jun 11 '13 at 9:09
  • Seems it works. I'll need to tune it a bit, but it can do the job. – Mołot Jun 14 '13 at 7:22
3

I am writing without testing but I have a feeling that you can use it at least as a starting point.

Using the Views Field View module, you can embed a view into another view, and it also allows you to pass a contextual filter to the embedded view.

In your case, I would create just another view that has a contextual filter that searches the given filter. I am not sure on that point, if you can make a search through contextual filters, but I have seen some options like 'Search: Term' etc.

Having said that, if you can achieve this first step anyhow, the rest is relatively simple.

In your original view, you add a 'No results behavior' under the advanced options section, and add a 'Global: View (Views field view)' and select the view you previously created, and pass the token for the exposed filter as a contextual filter to the embedded view (you can find the tokens in the list for the replacement patterns).

  • 1
    Interesting idea but I couldn't get it to work. Lot of configuring and then Bala posted ready-made module and I lost my heart. – Mołot Jun 11 '13 at 10:42
  • Yes, i didn't know about the Finder module. I think I will use it in my projects as well. I would be glad if you let us know with a comment, if Finder does what you expect. – Елин Й. Jun 11 '13 at 10:47
3

I have gone through the above discussions and possibly the below scenario can address the post 'How to combine views exposed filter with search?'. The implementation will require some custom coding.

  1. Consider the url http://www.seedandspark.com/studio.
  2. Here, on Left hand side, you have a search form. This is a custom form (form_id = 'sns_studio_form_filter').
  3. On the content region we have around 7-8 view blocks & all generating dynamic information (for anonymous users 3 blocks only)
  4. Now, we have exposed filters enabled with each view block.
  5. We have kept those exposed filters hidden from view
  6. We have kept a note of the url structures when we use view exposed filters
  7. In our custom form submit handler, we take information from the fields of the custom form and generate the similar url as we have noted in step 6. And, finally we redirect to that url. It will be like this in the submit handler ::

    $form_state ['redirect'] = array(
      $path, 
      array(
        'query' => $params // $params is the url
      )
    );
    drupal_redirect_form( $form_state );
    

So, now once step 7 is executed, all the view blocks will get filtered based on the filter criteria you have set.

Hope it helps.

3

There's also another way of doing it: You could try out Concat Field module. You basically add the field to content types, and then you can use filter by this field as search.

It's quite similar to Finder, I agree, but I think it's still worth mentioning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.