By Mołot


2013-06-06 11:14:55 8 Comments

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?

4 comments

@32i 2013-07-30 10:10:02

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.

@dhrubaj 2013-06-13 10:35:37

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.

@Bala 2013-06-09 06:04:11

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

@Mołot 2013-06-11 09:09:51

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 2013-06-14 07:22:11

Seems it works. I'll need to tune it a bit, but it can do the job.

@Елин Й. 2013-06-08 12:16:49

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).

@Mołot 2013-06-11 10:42:40

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.

@Елин Й. 2013-06-11 10:47:58

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.

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] Exposed Views Combine filter not working

  • 2017-03-27 11:03:34
  • visabhishek
  • 250 View
  • 1 Score
  • 1 Answer
  • Tags:   8 views

3 Answered Questions

[SOLVED] combine several exposed filters into one exposed (search) form?

  • 2012-08-23 14:05:06
  • Math
  • 6928 View
  • 4 Score
  • 3 Answer
  • Tags:   views

1 Answered Questions

[SOLVED] Drupal Views Search: Creating an Exposed Filter with Checkbox Options

  • 2016-04-03 19:54:04
  • Sage
  • 529 View
  • 2 Score
  • 1 Answer
  • Tags:   views search

3 Answered Questions

[SOLVED] How to search views with exposed filters

  • 2012-05-24 12:39:41
  • miske
  • 1238 View
  • 1 Score
  • 3 Answer
  • Tags:   views search

1 Answered Questions

Views Exposed Filter conflicting with default search

  • 2013-10-20 19:33:47
  • CR47
  • 89 View
  • 0 Score
  • 1 Answer
  • Tags:   7 search views

1 Answered Questions

[SOLVED] How to get taxonomy synonyms working robustly with Search API?

  • 2012-09-09 16:59:27
  • user56reinstatemonica8
  • 3586 View
  • 20 Score
  • 1 Answer
  • Tags:   7 taxonomy-terms search

Sponsored Content