Recently I’ve been updating a Drupal 6 website to Drupal 7. One of the new features is to enable site-wide searching of content (in Drupal 6 a design oversight had not included themeing for search forms — so we’re rolling that in now). There are a plethora of searching modules — but I’ve always wanted to use built-in search but tweak (without much hassle!) how the results are displayed. Today I finally utitlized the Display Suite Search submodule. Since I’m using DS on my website already, all I had to do was familiarize myself with the options DS Search provides me.
By default the Drupal search page is rather blah:
I would love if the search page:
- told the visitor how many results their search produced.
- allowed me as a site manager to tweak how each result is rendered.
- could control per item rendered what field(s) are shown per content type.
In general the DS Search module allows me to achieve all 3 customizations. DS Search integrates/extends the Core search module and supports Apache Solr Search. On my website I limit access to content using the Rabbit Hole module.
After applying our DS Search customization my site search page appears as follows:
The output contains:
- A total results value count, and the keyword(s) searched for.
- highlighted search term per result.
- per-content type result display rules.
- similar content type results are grouped per-page of the search results.
In order to achieve this I enabled the DS Search module and altered the default Search Settings of Drupal and also the DS:Search settings:
In the default site search settings for Drupal we tell Drupal to use DS:Search as the module and output mechanism for searches. At any time we may “go back” to the Core mechanism if we want by simply selecting Node here.
Then for Display Suite we configure it’s search options:
Using the DS:Search settings we can do many things such as:
- tell Drupal how to render each result item (Teaser, Full Node, Trimmed, etc).
- Should we show the title?
- Should we include a total results count value?
- How about keywords?
- Do we group results per page?
… the list goes on! What I see as nice about this is as a site administrator I do not have to write any code and I’m getting alot of customization out of the box by leveraging Display Suite throughout my website.
Lastly, if I want to change how some piece of content is shown in Search Results I again make use of DS and override the view_mode for Search Result Highlighting Input to whatever I want to show. Here is an example for my Page content type, I don’t want to show attached files if any exist on the Node on the search results page:
These view_modes and overriding the output of these results should feel comfortable if you’re used to using Views or creating Content Types in Drupal.
I hope you can see how flexible and powerful DS:Search can be!
Looking for quality web hosting? Look no further than Arvixe Web Hosting!