Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
If you'd tried building a forum in Drupal, you've already encountered a way of defining content with categories known as Terms. In that case, each term you've defined became the name of a forum, but Drupal system of categorization has uses well beyond that simple example and in fact, is essential to advanced functions you might want to add later to your Drupal site. Before we go on, let's take a look at what exactly categorization does for a site. We'll do that by looking at Lynda.com. On Lynda.com, you can see the videos that are available according to product or vendor, the number of other categories or you can look at All Courses. Let's do that now. On this page, you can see that Acrobat 9 Pro Essential Training shows up in the Acrobat 9 category, which makes perfect sense. That's because this video has been tagged Acrobat 9. But you'll notice it also shows up under Acrobat. So, it has two tags to it; Acrobat 9 and Acrobat. The good thing about this system is nobody has to maintain this page specifically; all they have to do is to add the correct tags and then build a system that will collect all the ones that have a certain tag and put them in one place. So, for example, if we go down to Product, Acrobat, we see only those that have the Acrobat tag. But enough about the Lynda.com site, let's go back to our Drupal site.
To start categorizing content, we go to Administer and Modules and make sure that the Taxonomy module has been turned on. It's automatically turned on if you've turned on the Forum module as we have done. In fact, you can't turn it off but it's required by the Forum module. If, however, it's not checked, you would check it here and then go down to the bottom of the page and click Save Configuration. Once you've done that, you are ready to administer your taxonomies. To do so, go to Administer and scroll down until you get to Taxonomy. Because we have already created forums, we see one taxonomy down here, which is Forum Topics. We are going to add one that's going to be specific for blog posts, so that when somebody posts something in their blog, they are forced to say exactly what category it falls into. We'll do that by clicking on Add vocabulary and we fill in the fields below.
For us, that will be name is Blog post categories. The Description will be Tags to categorize blog posts and for Help text, we'll just add, Help others find related blog posts. Continuing down, we can say what sort of content type we want this to apply to. We are only going to categorize our blog entries, so we'll click there but we could do multiple content types. At the bottom of this screen, we have three settings that are specific to taxonomies. One of them is Tags. The difference between Tags and an ordinary taxonomy is that with a standard taxonomy, the user can only choose from categories that you've already defined. With Tags, they can enter their own categories. We'll show exactly how that works in a moment.
Multiple select, as might imagine, allows people to include several categories in their posts and finally, Required will force them to enter at least one category in their post. We are going to turn on Required here and click Save. Very good, now let's see how this affects an ordinary user. To do that, we are going to switch to Fishy Joe's account. He is logged in, in the Firefox browser. And let's take a look at all of the blog posts. We do that by going up here and going to /blog and we can see that here is one that Fishy Joe has posted. Let's go into it and edit it. You'll notice a new option, Blog post categories, in that little orange star means that it's required. If Fishy Joe decides not to add on, we'll see what happens.
Ah! He is one that he has to. So, now he would have to choose something here but for right now, he doesn't have anything to choose, let's go back to our administrative interface and give him some options. So, we are back Administer and Taxonomy and at the bottom, we have Blog post categories. Now, we list the terms and see there's nothing there, we need to add additional terms and these terms will be what Fishy Joe will be selecting from. Let's call a term Buying.
For Tags, I suggest that you only have single words to avoid confusion. Under Advanced options, we can choose whether that term is the child of another term or the parent of another term and create a hierarchy of terms. We can also say, whether it's a synonym for another term. We won't get into any of those advanced options at the moment, instead we'll click Save and you'll notice that it leaves you on the Add terms screen. That's because typically, when someone is creating a taxonomy, they create several terms at once. I am going to add Selling and I'll create Properties. I think that's enough terms for now. Well, let's add one more. Lifestyle. Very good. Now, let's go back to Fishy Joe's account and view this note again and edit it again.
Now, when we go to Blog post categories, we can see that there are several choices there that he can choose from. In this case, he is talking about buying properties, so we'll select Buying and say Save. But here's the thing; he is talking about buying but he is also talking about properties. Maybe we should let him select more than one. Well, let's go back to our administrative interface and make that so. To do so, we go back here and Administer and Taxonomy. From there, we can edit our vocabulary, scroll down to the bottom and allow a multiple selection. Scrolling down further, we save it and then let's go back to Fishy Joe and see how that affects the ordinary user. Click again on Edit. Now, you'll notice it's a different sort of menu and if you hold down the Command key on the Mac or the Ctrl key on a PC, you can select more than one.
In fact, you can hold down the Shift key and select all of them by selecting the first one and then the last one, but we are just going to have Buying and Properties. Scroll to the bottom and save. Very good, you'll notice that those tags show up after the post. So for example, by clicking on Buying, we would show all such posts that were about buying because they had been tagged as Buying. There is one last thing we are going to do by switching back to the administrative interface. Let's got back to that taxonomy, edit the vocabulary and scroll to the bottom again. This time, we are going to let it be free tagging and we save it and see how it affects an ordinary user by going back to Fishy Joe. Let's edit it one more time and you see that instead of having a drop-down menu, it's this list into which he can freely add tags. There's something interesting here, which you see in this little circle. Let's just try typing Buying. Ah! It notices once you start typing that there is something in there already called Buying.
If I do comma and do another one and we can start typing the next one. Ah! Properties, it recognizes that. So, we'll click on that. We'll then scroll to the bottom and say Save and there we have it. We have tagged our Blog post as Buying and Properties. If we want to see all the properties tagged to blog posts, we would just click there and there we are. Of course, we only have one at the moment but we could have many as the site grows. As with any other part of your site that's open for user interaction, taxonomies can be abused. One way to avoid such problems is to limit categorization only to those pre-determined tags that you have defined.
Get unlimited access to all courses for just $25/month.Become a member