Filtering certain pages by Taxonomy Classification


Complexity Level: Intermediate

This is an intermediate topic. You will need to possess some basic understanding and have some experience with Drupal content editing.

Permission Level



This page is directly adapted from a series about creating a special section for your site, such as one used for a conference, program or other reason. So in the example, we'll be adding a category for Event types. 

If you need additional help please see our Drupal 10 Support page.

Overview

These steps cover how to create a new classification or checkbox-- called a taxonomy term-- in certain content templates on your website for the purpose of creating menu links to filtered content. 

You can see in this example graphic we have a taxonomy on our event content type, and the classification options are: Seminars, Faculty Visits, Guest Speaker, Big Conference 2021.

Think of taxonomy as a way of classifying content. Only certain content types use taxonomy in our sites: Events, News, and Personnel. Once content is classified, you can use it to "filter" content by the classification. While we designate which content types contain the taxonomy filter, you determine what options are available for taxonomy on each content type. 

Table of Contents

Steps

You can use taxonomy to filter out content tagged with specific terms, much in the way we filter out Faculty from the main Directory pages. 

We'll create new categories or terms using Drupal's taxonomy functionality. But we'll also need to work with the menu. Our example will be with the Events content type.

Note, Events tagged with any new terms will also show up in the main Event section of the website, including spotlights. If you don't want this to happen, put in a ticket to the web team via helpdesk.franklin.uga.edu

Introduction

Right now all of my content made with the "Events" content template appear on my website under /events/all.

But what if I want to draw attention to certain types of events, such as a named lecture or conference? 


When I click on edit for an event, I see a collection of options under "Type of Event." 


We're going to add a type of event to this list using taxonomy.


For our example, I'm going to pretend that I want to add a category of event called "Big Conference 2021," so I can see all events tagged with this in one list, something like this:


The next step will show how to do that. 

Step 1 - Create a new taxonomy term-- a new event category-- in "Event types."

In the admin tool bar, go to Structure.

Scroll down until you see "Taxonomy" and click this. 


Here you can see all the taxonomy vocabulary used throughout your site. 


Look for "Event types." Select "List terms."

Note, do not mess with anything called "Localist," as these terms are predetermined by the UGA Master Calendar. 


Once you click on "list terms" for the "Event types" vocabulary, you'll see all the terms. These appear as checkboxes when you are editing a piece of Event content. 

Notice the blue "Add term" button. Click it so we can create a new type of event for our conference.


When I click add term, I see a title field and a text editor field. The only thing we really care about is the title field, called "name."

Type in whatever you want to call this kind of event related to your conference. I'm just going to call it "Big Conference 2021."


Hit save.


After this you can add other terms or types of events if you want.

In this example, I'm just creating the one category for conference events.  

So to see the new term show up in the events taxonomy list, Click on "taxonomy" from the breadcrumb trail, then "list terms" again next to "Event Types."


And I see my new term in the list of Event Types.

I'm going to rearrange the term so it appears at the bottom by using the plus sign and dragging. 

Hit save to preserve the new order.

Now when I create a new event, I will have the option to select a type of Event called "Big Conference 2021."

Can I edit an existing category or term?

Yes, but be careful, because it is likely you will need to update menu links (especially if you change Personnel positions/types).

For example, if you were to change the name of the category "Faculty visits," which is at in the menu at the /events/faculty-visits url, to "Guest Lectures," /events/faculty-visits will cease to work. You will need to remember to update the link in the menu to /events/guest-lectures. 

Every Event that was tagged as "Faculty visits" will remain checked or tagged; they'll just be called "Guest lectures" now. You only lose existing tagging when you delete a category or term. 

What happens if I delete a category or term?

You will lose existing tagging when you delete a category or term. So if I delete "faculty visits," there will be no Event content tagged as Faculty visits. The content itself will still exist, but its tagging for that category will be gone.

There is no way to undo deleting a category or term.

Step 2 - Create an event and tag or check it with your new event category

Before we do anything else, let's go ahead and make an example event tagged with our new term. 

Go to Content. Select "Add Content," then "Event."


Create your conference event. Check "Big Conference 2021."

Hit save.



But how do I create a list of Events checked or tagged as "Big Conference 2021"? 


Step 3 - Put the list of events checked with your new term in the menu

As your developer I have already made it possible for you to filter out any event tagged with any term you create. 

In our example, all events checked or tagged as "Big Conference 2021" will appear under /events/big-conference-2021.

See for yourself. 

So we just need to add this correct url to the menu. 


In the black admin toolbar go to "Shortcuts" and select "Manage main menu."

If I scroll down, I see all my Conference pages. 



Go back to the top and select "Add link."


Add a menu link title, whatever you want to call it. 

Because this list of Events is going in a separate section of the site, and not under the main Events section, I'm just calling the link "Events." 

You can tall the menu link title whatever you want, and you can change it later too. 

Now add the url. It will follow the pattern of /events/name-of-term-you-added. In our example, /events/big-conference-2021.


Scroll down to "Parent link."

Put your link under whatever page you want it to go. You may want to put it under the main "Events" page.

In this example, I'm putting it under my conference Basic Page called "Conference 2021."


Hit save.


Now when I scroll to the Conference pages, I see my new "Events" menu link.


I'm going to rearrange the link order and put Events at the top. I've also decided to disable the "Event Schedule" page. This is just my preference.


Because I rearranged links in the menu, I need to hit the save button. 


So now my Big Conference 2021 events are part of the conference menu. Notice the "Events" link to the right. 

Note, these events will also show up in the main Event section of the website, including spotlights. If you don't want this to happen, put in a ticket to the web team via helpdesk.franklin.uga.edu

Besides Events, where else can I add categories on my site?

We used Events as an Example, but you can add categories-- taxonomy terms-- in other places too. The ones that are used the most are Personnel and Article. Sometimes the field name doesn't match up with the vocabulary name, so I've created a table below to help you match things up. 

Please don't change any vocabulary that says "localist" in the title; we need these exact terms for the UGA master calendar. 

Content type and field nameTaxonomy Vocabulary NameNotes

Personnel

Position

Personnel Types


This is where you can do the most damage if you edit existing terms, because we usually have a filter on every category in the menu.

For example, if you were to change "Core faculty," which is at in the menu at the /directory/core-faculty url, to "Regular Faculty," /directory/core-faculty will cease to work. You will need to remember to update the link in the menu to /directory/regular-faculty.

Article

Type of News/Audience


News/Article/Audience Types



Most folks aren't using this vocabulary. If you don't see that "Type of News/Audience" field in Article and you want to use it, please put in a helpdesk ticket with the web team.


You'll notice that there are far more vocabularies under "Taxonomy" than this, but it is likely that I haven't set up contextual filtering for these, and some of them, like the localist categories used for the UGA master calendar, are ones we don't want to mess with.