Cool module: Finder
Share with Others
This is a guest post from Daniel Sipos, a Drupal enthusiast from Brussels. You can follow him on his blog.
There is a really powerful module out there designed to help with searching through your Drupal content. It’s called Finder and gives you a lot of power in filtering down or searching for content. For this article I chose 2 things about this module that I personally found very useful: searching (filtering) via autocomplete widgets and the ability to have blocks that hold this search functionality.
Apart from searching via the Drupal search module, a classic way of allowing your users to search through content is by using exposed filters in Views. This allows users to apply filters to a Page View and narrow down the results of the View according to those. The Finder module is based on Views as well inasmuch as it takes its content from a View (which in my opinion makes it very highly customizable).
Therefore to start using the Finder module, you need to create a View with the necessary content and based on that you can add a new finder. This newly created finder (however configured) will then use the results of this previously created View as content to search through.
You add a new finder like in the image below:
Once you created the finder, you can configure it and add elements to it. There are 4 types of elements you can add: select list, text, checkboxes/radio buttons and autocomplete text. Elements are the widgets you actually use when performing a search. The first three can be used also directly in a View with exposed filters - but not the autocomplete widget.
1. Autocomplete widget
Although the Views exposed filters are widely used and for good reason, I found myself wanting the possibility to let my users search through nodes using autocomplete widgets. You know, like when you add a new taxonomy term to a node, you can use the autocomplete widget to type the term in, and if the term already exists, it responsively lets you know.
The form for adding a new element into the finder is depicted in the image below:
So after you create your View and Finder, and after you added a new element (in this case an autocomplete), you have to configure the element. The most important thing you need to set is the Field(s) the element will look through when you are typing something in. Note that this is correlated with the Views fields so if you want the element to look through a specific field, make sure it exists in your View.
For the sake of simplicity in this example (and probably common usage too), I will add the Title field as the main field my autocomplete widget will search through (see image below).
Once you added the field of your choice, you can already test your finder by going to the path you indicated under the BASIC configuration fieldset. Pretty neat a? If you go back to configure further your finder you’ll find a bunch of options to customize and make it look the way you want it. You can add description, header, footer etc.
More importantly however, you can select the value and field logic (for when you have multiple fields for one element), as well as the matching type (such as contains, equals, starts with etc). What is thus pretty cool is that you can have more elements per one finder and combine them to search and filter through your View (similar to Views exposed filter). Moreover, you can add Ajax so that as you type in the autocomplete, the results filter down automatically as well. I really encourage you to further explore these capabilities.
2. Block finder
In the finder configuration, under BASIC, you can set the path of the page where you will be able to see your View with the finder elements on top for filtering. However, you can also check the box to create a block for the finder. This way, you can place a block in a sidebar (or god knows where else you may be thinking - Display Suite..pfuu the possibilities..) and search through that View from there. To illustrate, I will use my favorite autocomplete widget from the previous example.
Once you added the block to the sidebar, you can go to your front page and start typing in it like in this example - hints will responsively show up in the widget. If you click on one hint, it will take you to the finder page (the one for which you can set the path in the configuration page under BASIC) and directly show you the result. If you add Ajax to the finder, it will also show the results in the block and narrow them down as you type. I don’t know the circumstances in which this last part can be useful for you, but without Ajax, it is pretty cool.
OK, so there you have it, just a touch on the capabilities of this module from my part. I am always open to comments.
Go crazy and like usual, hope this helps. You can follow me on Twitter at @drupalexp