What you will learn
In this article, you will learn about:
- Using Taxonomy to link descriptive terms to Node Content
- Tag clouds
- Path aliases
What you will do
In this article, you will:
- Create a Taxonomy
- Enable the use of tags with Node Content
- Define a custom URL
- Activate site searching
- Perform a search
One way to find content on a site is by using a search function, but this can be considered as a hit-or-miss approach. Searching for an article on 'canines' won't return an article about dogs, unless it contains the word 'canines'.
Certainly, navigation provides a way to navigate the site, but unless your site has only a small amount of content, the navigation can only be general in nature. Too much navigation is annoying. There are far too many sites with two or three sets of top navigation, plus left and bottom navigation. It's just too much to take in and still feel relaxed.
Site maps offer additional navigation assistance, but they're usually not fun to read, and are more like a Table of Contents, where you have to know what you're looking for.
So, what's the answer?—Tags!
A Tag is simply a word or a phrase that is used as a descriptive link to content. In Drupal, a collective set of terms, from which terms or tags are associated with content, is called a Vocabulary. One or more Vocabularies comprise a Taxonomy. This a good place to begin, so let's create a Vocabulary.
Activity 1: Creating a Taxonomy Vocabulary
In this activity, we will be adding two terms to our Vocabulary. We shall also learn how to assign a Taxonomy to Node Content that has been created.
- We begin in the Content management area of the admin menu. There, you should find the Taxonomy option listed, as shown in the following screenshot. Click on this option.
- The next page gives us a lengthy description of the use of a taxonomy. At the top of the page are two options, List and Add vocabulary. We'll choose the latter.
- On the Add vocabulary page, we need to provide a Vocabulary name. We can create several vocabularies, each for a different use. For example, with this site, we could have a vocabulary for 'Music' and another for 'Meditation'. For now, we'll just create one vocabulary, and name it Tags, as suggested below, in the Vocabulary name box.
- In the Description box, we'll type This vocabulary contains Tag terms.
- In the Help text box, we'll type Enter one or more descriptive terms separated by commas.
- Next is the [Node] Content types section. This lists the types of Node Content that are currently defined. Each has a checkbox alongside it. Selecting the checkbox indicates that the associated Node Content type can have Tags from this vocabulary assigned to it. Ultimately, it means that if a site visitor searches using a Tag, then this type of Node Content might be offered as a match. We will be selecting all of the checkboxes.
- The Settings section defines how we will use this vocabulary. In this case, we want to use it with tags, so we will select the Tags checkbox.
- The following screenshot shows the completed page. We'll then click on the Save button.
- At this point, we have a vocabulary, as shown in the screenshot, but it doesn't contain anything. We need to add something to it, so that we can use it. Let's click on the add terms link.
- On the Add term page, we're going to add two terms, one at a time. First we'll type healing music into the Term name box. We'll purposely make the terms lower case, as it will look better in the display that we'll be creating soon.
- We'll click on the Save button, and then repeat the procedure for another term named meditation.
- The method we used for adding terms is acceptable when creating new terms that have not been applied to anything, yet. If the term does apply to existing Node Content, then a better way to add it is by editing that content. We'll edit the Page we created, entitled Soul Reading. Now that the site has the Taxonomy module enabled, a new field named Tags appears below Title. We're going to type soul reading into it. This is an AJAX field. If we start typing a tag that already exists, then it will offer to complete the term.
- Now, we can Save our Node Content, and return to the vocabulary that we created earlier. Click on the List tab at the top of the page. Our terms are listed, as shown in the following screenshot.
Taxonomy isn't listed in my admin menu
The Taxonomy module is not enabled by default. Check on the Modules page (Admin | Site building | Modules) and make sure that the module is enabled. For the most part, modules can be thought of as options that can be added to your Drupal site, although some of them are considered essential. Some modules come pre-installed with Drupal. Among them, some are automatically activated, and some need to be activated manually. There are many modules that are not included with Drupal, but are available freely from the Drupal web site.
If a new Node Content type is created that will use tags, then edit the vocabulary and select the checkbox.
In computer terminology, a Cloud is a gathering of loosely-related items with something in common. An example of such a phenomenon is a playground at a fast-food restaurant where several highways intersect. The kids aren't necessarily tied by ethnicity, nationality, age, sex, citizenship, home town, destination, nor 'herd'. The two commonalities are that they're all kids and all Homo Sapiens (although, they might seem like they are from Alpha Centauri).
A Tag Cloud is a grouping of terms that don't necessarily have any relationship to each other with regards to their meaning or context. The only factor that typically links the terms is that they are all related to the content on the same web site.
Tag Clouds are normally represented as a rectangular region in which the terms appear as different typefaces and font-sizes, so that each term stands out from its neighbor. We're going to use two types of Drupal Tag Clouds, which means that two different modules will be used in order to show us different examples. The first one is called Tagadelic, and the other, Cumulus. The only difference between the two is that Cumulus presents the tags as a flash movie. Putting one's mouse over the cloud causes the tags to start moving within the cloud as if it were in 3D and they were hailstones. The words actually appear to move away (get smaller) and cycle around as they draw closer again.
The Cumulus module depends on the presence of the Tagadelic module, both are add-on modules. Even though both are present, the Tagadelic module's output doesn't need to be enabled on the page, unless you want it to be shown. We're going to use one of each Cloud type. Each Tag Cloud module creates a Block for its Tag Cloud. For now, both modules have been configured and assigned to the right-hand column. These modules, as well as the tags, can be seen in the following screenshot.
We named the Tagadelic tag cloud, Index, and the Cumulus tag cloud as Cumulus Tag Cloud. Both of them present the tags as links. We'll click on the link for meditation, and the result is shown in the following screenshot.
My Tags Don't Show Up
When new Tags are added, there are two things that you may need to do in order for them to appear in the tag cloud. The configuration for the Cumulus tag cloud has a Clear Cache button, and the Performance page (admin/settings/performance) has one as well. They are two different caches. Moreover, even though the Performance page might say that caching is disabled, theme contents are still cached, so click on the cache-clearing buttons at both locations.
The whole idea of the Tag Clouds is that a site visitor, without knowing much, or knowing little-to-nothing about your site's content, can scan the tags for a subject that they are interested in, and click on it.
Every web page that you visit has an address, or URL, that is listed in the address bar of your web browser. If you've paid attention to the URLs in your web browser, then you've probably seen quite a few that look as though they span a paragraph in length. This doesn't affect the visitor's ability to get to the page. After all, clicking on a link is clicking a link, regardless of its size. However, if the person tries to remember the link, or needs to write it down, then it gets ugly. Beyond that, it's nice to have URLs that are actually meaningful for the search engine 'spiders' that crawl the Web and index everything.
This begs the question, "where do the URLs come from?" The answer, with regards to Drupal, is that they are created by the software, and they're not pretty. Here is the URL for the Soul Reading page that we just looked at.
Not very helpful at all, is it? Fortunately, we can make this link much nicer to look at, and much more meaningful. Drupal comes with a Path module. The term 'path' refers to the portion of the URL that follows the domain name: node/15 in the example above. The Path module allows us to create an alias path. The original path will still exist and be usable (Drupal will continue to use it internally), but the path that is presented to the site visitor (and the search engines) will be the alias. Let's create an alias for one of our articles.
Activity 2: Creating a Path Alias
We'll edit Music for Your Spleen. Beneath the Comment settings link is a link to the URL path settings option. If it's not present, then the Path module needs to be installed and/or enabled. Click on the link to open the dialog.
In the text box provided, we'll simply enter spleen, and then Save the Story.
Now, the URL for the page is as seen in the address bar of the browser in the following screenshot.
Aside from the navigational aids, one of the landmarks that site visitors always expect to see is the search box. It's very frustrating when a site's navigation doesn't offer a path to where you want to go, and there's no search box to be found.
Activity 3: Enabling the Search functionality
The Search module is included with Drupal. All that we need to do is to turn it on, and tell Drupal where we want it to appear.
- We'll select the Site Building option from the Administer menu, and in the Site Building option, we'll select the Modules option.
- Some way down the page is the heading named Core. The modules listed in this section are part of the Drupal installation. We select the checkbox next to Search, and then click on the Save Configuration button at the bottom of the page.
- Next, we'll click on the Blocks option from the Administer menu.
- On the Blocks page, towards the bottom of the Disabled section, we find a row for the Search form option. Beside the name, we'll click on the arrow in the drop-down list box, and then select the left sidebar option, as shown in the screenshot below.
- The row has now moved higher up the page to the left sidebar section. We need to click on the Save blocks button at the bottom of the screen to save our change.
- Next, return to the Home page, which is the front page, and we find the Search box in the left column. We'll enter healing into the box, as shown in the following screenshot.
- The Search results are shown in the screenshot that follows. You'll also notice that at the top of the results is a link for an Advanced search, should the search need to be made more granular.
Searching and advanced searching are actions that are controlled by permissions, so the search box and/or the advanced search link may not be visible to every user role.
My searches yield no results
If your searches consistently return no results, then it is because the site has not been indexed. Navigating to the Reports menu from the Administer menu, and then to the Status Report, will lead you to a link for running Cron manually. This will cause the site to be indexed.
In this article we learned about:
- Using Taxonomy to link descriptive terms to Node Content
- Tag clouds
- Path Aliases
These topics have been learnt with the help of activities in which we:
- Created a taxonomy
- Enabled the use of tags with Node Content
- Defined a custom URL
- Enabled site searching
- Performed a search