311: Joomla 3.1 Search Component Tutorial

The Joomla Search component allows you to do two things - view statistics about what people are searching for on your site and customize the available search settings. In this tutorial, we'll cover both of these topics, starting first with search statistics.

Search Statistics

Enabling gathering of search statistics

When you first access the Joomla Search Component, you'll see a Gathering statistics disabled error message. To being using the search statistics feature, we'll first enable statistics gathering.

Set the Gather Search Statistics setting to Yes, and then click the Save & Close button towards the top of the page.

The page will refresh and then you will see a message that says Gathering statistics enabled.

Viewing what users are searching for

In our testing, we used the search module on our website to search for the following words (each one in a separate search): apple, orange, and fruit. Using the search statistics feature, we can see information on these searches that we just performed.

That's it! As you can see in the screenshot to the right, Joomla shows a listing of all phrases searched for on the site, how many times each phrase was searched for (referred to as hits), and the number of results for each search.

Showing the number of search results

In the screenshot above, you can see under the Results column it simply says Off. If you want to see how many search results are returned for each search phrase, find and click on the button that says Show Search Results.

In our testing, we don't have any articles about oranges, apples, or fruit. We do have a few articles about the word blog, so we'll show you how the Results feature works by searching our site for blog.

As you can see in the screenshots below, we have 9 results for the word blog, and the search component similarly shows 9 search results.

A search for the word blog

Results data shown in the search component

Reseting search data

For busy websites, your users may search on your website quite often. With so much data showing in the search statistics, it may make it difficult to find the information you're actually looking for. Clearing the search statistics will remove all data, and allow you to start fresh.

You can see below what the search statistics look like before and after we click the reset button.

Before clicking reset

After clicking reset

Search Options

There are several options available that you can use to customize the way your Joomla site's search works. Below, we will show you how to access these settings, and we will also explain what each of them controls.

Adjust the settings as you see fit, and then click the Save button in the top left of the page. Below is a summary of several of the settings.

Use Search Areas

The Use Search Areas setting gives your users the option to search only through certain types of content. For example, if the user only wants to search through Newsfeed and not Articles, using the search areas feature (shown to users as Search Only) they can do this. If you disable this setting, the Search Only feature (highlighted in the screenshot to the right) will not show to users.

Created Date

By default, when you search a Joomla site, in the results the date the article was created on will show. If you disable the created date feature, the search results will no longer show the Created on data. In the screenshot to the right, we've highlighted the created on feature so you know exactly what it is we're referring to.

OpenSearch

Are you familiar with the Google search bar in the top right of your firefox browser? That's an OpenSearch feature. If you see in the screenshot to the right, when you're on our Joomla site's search results page, users have the option to add a custom OpenSearch toolbar, which will allow them to quickly search our site, and only our site.

OpenSearch was developed in 2005 by Amazon. In our many years in technical support, the phrase OpenSearch has not come up often, but most everyone is familiar with what it is (but maybe not its name).

The Joomla Search Component includes two OpenSearch settings, OpenSearch Name and OpenSearch Description.

In our testing, we entered the following settings:

OpenSearch Name

Joomla 3.0.2 Testing site

OpenSearch Description

This website is driven by Joomla 3.0.2, and is used as a testing ground for testing Joomla.

Now that we've adjusted these settings, how do we see what has changed?

Go to your Joomla website and perform any search. Then view the source code of the page and you should see something similar to the follow:

We'd love to tell you what all this means, but it honestly isn't something we're very familiar with. The take home point is that the Joomla allows you to customize these OpenSearch settings if you need to do so.

Search for

If you notice in the screenshots above, the search feature includes a Search for option. This option allows users to search either for All words, Any words, or Exact Phrase.

We received a question on how to hide this functionality. There does not seem to be a setting in Joomla to do this. To accomplish this however, we can edit our template's CSS.

To hide the Search for feature, edit your template's CSS file and add the following code to the bottom:

#searchForm fieldset.phrases {display:none;}

If you're using the protostar template, this is the file you will need to edit:

templates/protostar/css/template.css

In our testing, using this 'work around' solved the problem. After making the change, be sure to clear your browser's cache so the update CSS file is used.