In the previous section, we gave an overview of Drupal taxonomies. This time, we will look at some examples of their use in practice.
Let's review taxonomies.
Concept of Taxonomy
- Taxonomy is a label used to sort articles.
- Set multiple taxonomies according to your purpose
- To use taxonomy, go to Vocabulary > Term Settings and set up terms to function as tags or categories
- To use the terms you have set up, you need to specify the vocabulary in the field of the content type you are using
- By adding terms to articles, a taxonomy list page can be generated and used as a category list.
- By using taxonomy as the filter condition in a view and vocabulary or terms as the filter condition, it is possible to create more flexible lists.
Let's look at some examples using the articles we have created.
Let's see what happens when we label and sort articles.
The articles on my site are broadly divided into two themes.
- Memorandum of the process of building a website while learning Drupal > Creation
- Articles on themes such as fashion and second-hand clothes > Life Style
We will set the terms Creation and Life Style for these two themes.
When writing an article for the Life Style section, select the Life Style content type and write the article. Before publishing the article, select Life Style in the tags field.
As an example
Let's take a look at the above example. At the bottom of the published page, you will see the following display.
Post: 2024-11-07
Contributor: S.Takeda
Tag: En Life Style
Article: En Photo Articles.
Shop: Leica Ginza Store
The Tags, Article content and Shop in this display are taxonomies.
Tags = Vocabulary: En Life style = Term
Article content = Vocabulary: En Photo Articles. = Term
Shop = Vocabulary: Leica Ginza Store = Term
The vocabulary fields set in the taxonomy are assigned to the content type fields in this article. When creating an article, the fields are displayed along with CKEditor and other tools. When you select a vocabulary field that is displayed, the terms registered in the completion function are displayed, so select a term that is appropriate for the article content. By selecting a term when creating an article, the selected term will be displayed in the article.
The terms you set at the bottom of the page are displayed as links. Clicking on a link will display a list of articles that have the same term selected. This is the basic way to use taxonomy.
If you add taxonomy elements to the above article and display the specified terms, you can use them as tag elements as is commonly done. As I mentioned in the previous section, one of the basic concepts of tags is that they do not have a hierarchy. The list of tags that you often see on blogs, etc., is a function called a tag cloud, which is a function that displays a list of tags registered in a separate field on a separate page from the article.
My own idea for building the site is that, as it is a small site, I won't add too many categories, and I won't install a large number of tags on the site, so there is no need for a tag cloud, but if the number of articles on this site increases, I will consider installing one so that it will be easier for visitors to find the articles they want to read.
Post: 2024-11-07
Contributor: S.Takeda
Tag: En Life Style
Article: En Photo Articles.
Shop: Leica Ginza Store
The terms set in the article above, Photo Article. Leica Ginza Store, function as tags.
The term ‘tag’ refers to the labels that can be placed on articles on a page to create a list of articles that have the same label. The purpose of this function is to allow viewers to see related articles and to organise keywords that are not sufficiently distinct to be divided into categories.
By setting the terms you have set up as a list in the menu, you can give them the function of categories. On my site, I have a navigation function that allows you to select a category in the top navigation.
Top Navigation Menu
|-- Home
|
|-- Life Style articles
| |-- All articles | Create a page with the taxonomy > tags > Life Style as the extraction condition in the view
| |-- Old-Clothes Articles. | Article > Display results for Old-Clothes Articles.
| |-- Fashion Articles. | Article > Display results for Fashion Articles.
| |-- Watch Articles. | Article > Display results for Watch Articles.
| |-- Photo Articles. | Article > Display results for Photo Articles.
| |-- Recommended shops. | Shop > Display results for Shop List.
The link destination uses the list page for each term set in the taxonomy. All articles are created using views, but the method for using the taxonomy function in views is explained separately in the view explanation, so we will omit it this time.
It is the same taxonomy element, but it is also used as a tag function to find related articles from the article, and as a category list to find categories from the menu. The view function is used for all articles, but it is the same as the taxonomy link. It is also possible to use the taxonomy display results in the menu list, but there are some advantages to using views. The views will be explained in a separate article.
We will look at taxonomy not just as a general tag or category, but also as a separate function.
As an example of how taxonomy can be used, I use it on the store introduction page.
We have set the vocabulary for the store in the article and are using the store as a term. As I explained in the previous section, you can set any field you like as the display result for the taxonomy, but by default, the field ‘Description’ is provided before the list view. This has HTML elements, so we have entered the store's information here, and the articles for the products purchased at this store are displayed in the list view.
One of the benefits of creating this page is that articles about the products you have purchased will be automatically added to the store page. You can also use views or block layouts, but this will increase the number of items you need to manage. By simply setting the store as a term in the taxonomy, you can manage the store introduction and related articles at the same time, so you can manage them efficiently.
I haven't found a solution yet, but I'm trying to set terms and manage the list of stores by term, but I'm not getting the results I want. It's obvious when you think about the principles, but the basis of taxonomy is labels for content, so I understand that terms without content cannot be displayed.
Although we won't be covering it in this article, the display of taxonomies is also managed by views. I'd like to take a closer look at this setting. The filtering conditions for views are based on constants, but the taxonomy views are based on variables, so if you understand this, you might be able to find a solution.
As a default feature of Drupal, there is a function that displays articles and pages on the top page. As it is only a function that sets whether or not to display articles and created pages, it is not possible to automatically set it to display only the three most recent articles in order by theme. This kind of setting can be achieved by combining taxonomy, views and block layout well. It is necessary to perform complex settings not only with taxonomy but also with other functions, but it is possible to display the information you want in the place you want in the form you want.
The top page displays three different vocabulary articles in order of most recent.
The vocabulary set in the taxonomy is setting into blocks in the view. The block layout is displayed on the top page.
Three new articles are displayed for each of the two themes. This new information is created by filtering the vocabulary using the taxonomy as the extraction condition in the view, and creating a block. This block is called and displayed on the Top page using the block layout.
This article explains Drupal's taxonomy over two articles. Compared to other functions, it is a highly functional feature that is easy to understand in terms of settings and usage. As it is not limited to a specific purpose, it can be used in a variety of ways depending on how you think about how to use it.
The basic function is to give articles and pages labels, and then use those labels in various ways. It is a basic function that allows you to think about how to display individual articles and pages in what form.
I often explain the concept of Drupal in terms of taxonomy, and it is built using vocabulary > terms. I often talk about how Drupal separates configuration and use, and here, too, configuration and actual use are separated, as vocabulary is used to configure fields, etc., and terms are used for actual use.
This allows you to give terms a page-like element, and makes it easy to use them in a way that differs from the general way of using taxonomy. It is an idea that came to me by using Drupal, which separates configuration from use and requires you to check the configuration items, although I would not have thought of creating and managing the store introduction pages I have introduced here using taxonomy in other CMSs.
As I often talk about in other articles, one of the advantages of Drupal is the need to make settings across multiple functions, and the high degree of freedom and applicability that comes from making settings in multiple functions. In this article, I wrote about taxonomy, but by combining it with views and block layouts, the range of ways you can use it will expand.
Next time, I would like to explain the view.
Views-1 Page
We will summarise the functions of the view, which allows you to list the articles and pages you have created according to certain criteria and freely arrange them within the site.