Read this blog on how to create custom search form in Drupal 7 for more information.
The Drupal core provides a Search module that is great for many sites. However, it doesn’t provide some of the more sophisticated features that some sites need. Search API can be tough to set up especially for new users to Drupal. For example, you need to understand the difference between a Search API Server and Index, and then you need to spend time configuring everything.
Drupal’s search module contains a powerful indexer which makes keyword searching efficient and accurate. On its own, the search module provides either a plain vanilla search field, or the advanced search form, but doesn’t provide a mechanism for customizing the offerings. It is an either/or proposition. The views module is well-loved for its ability to let you define a custom set of content on your site, and through the use of exposed filters, allow the site visitor to narrow the selection even further. These two modules can be glued together and made to cooperate using the views fast search module. In this article, I will show how to build a search form that has filters for taxonomy terms and content types.
How to Add a Drupal Custom Search Engine in Drupal 7 Using ExpertRec
Here we will visit the steps required to add the ExpertRec Custom search engine to your website. This is one of the easiest setup processes of all the available options out there and is highly recommended.
- Navigate to https://cse.expertrec.com/newuser?platform=cse and signup with your Google ID.
- Enter your website’s URL when prompted. You can select a server location near you and add the URL of your sitemap if you wish to. These will be auto-detected otherwise.
- You can play around with the settings and customize the UI as the crawl runs. Once it is complete, you can check out a fully functional demo before taking the search to your website.
- Download and Install Google tag manager extension for Drupal from here: https://www.drupal.org/project/google_tag
- Once you install, enter your Google tag manager ID. Click on save configuration.
- You can take the search to your website with little to no effort. All you need to do is to paste the code snippet available on the dashboard.
- Add this code to your Google tag manager.
- Add Triggers ( set to all pages).
Add a Custom Search Form to Drupal 7 Header
- Go to Structure-> Block layout-> Header ->Place block-> Add custom block-> click on source and enter the following code. (choose full HTML). This places the search box in your header
- Click save.
- Now the search box will be added to the header section of your Drupal site.
ExpertRec comes with more customization options that you can explore. You can read this article to find a more detailed guide on the installation and configuration.
Using Google Custom Search Module for Drupal 7
If you want a free alternative, then Google Custom Search Module is something to check out. The working is similar to the one mentioned above but this will give a Google-like search experience on your website and it is free of cost. It does have some limitations though. GCS comes with ads, which can be a major UX letdown. It also uses the default Google index and does not give you control over indexing or ranking so this is something to keep in mind. Google Custom Search is definitely an upgrade from the default Drupal search but I wouldn’t recommend using it on most websites.
Drupal 7 Custom Search Results
Drupal comes with many customization options. But when it comes to the search engine and search results page, customization gets quite tricky. On top of this, there aren’t many guides out there on how this can be done. If you made a custom search using either of the above methods, you can customize the search results page. While GCS allows minimal customization, ExpertRec does not have any restrictions to the changes allowed.
Once you have the search live on your site, you can use the ExpertRec dashboard to customize the search to your liking. You are free to customize both the appearance and the search results ranking criteria. This is by far the easiest way to customize your Drupal 7 Custom Search Results page.