Drupal 7 Tutorial Part 19: Understanding Drupal 7 Content Types & Fields Concepts !
Drupal 7 Tutorial Part 13: Drupal 7 Taxonomy, Vocabulary, Terms, Tags, Categories Concepts
Nice to see so many drupalers are following my Drupal 7 tutorials. As per your choice i would like to discuss about Drupal 7 Taxonomy Concepts.
What is Taxonomy in Drupal:
- Taxonomy is a concept in drupal which is basically used for categorizing content (nodes) in your drupal site.
- For example, let's say you have a content type called movie and you want to classify movies as Action, Horror, Romantic, Comedy, Drama etc then you need to know about Drupal 7 Taxonomy, Vocabularies, Terms or Tags etc.
- Let's have a hands on using taxonomy concept by implementing it as explained below.
- In Drupal vocabulary is nothing but a name given to group of terms which are used to categorize content. For example let's say you want to categorize movies as Action, Horror etc as discussed above then you will create a vocabulary named Movie Genre and then you will add above movie categories as terms inside this vocabulary.
- Let's get hands on using Taxonomy concepts and categorize Article Content Type Contents into various categories as Sports, Business, Breaking , Political etc etc...
- Let's create a vocabulary called "Article Type" and add above terms. To create a new vocabulary Login as administrator >> Click on Structure Link in the top black menu bar >> Then click on Taxonomy link at bottom to access list of vocabularies as shown below.
- To create a new vocabulary click on Add vocabulary button as shown above and in the next screen Add Name as "Article Type" and Description as "Vocabulary to classify article content type." Then click on save. Once you create vocabulary you can see it in list of vocabularies as shown below.
- Now let's start adding terms to our vocabulary. Terms are nothing but categories of articles which we want to classify as. To add terms click on add terms link next to Article Type Vocabulary.
- You will see screen like below to add new term. Give name as "Sports Articles" and description as "Sports Related Articles List." URL alias as "articles/category/sports" which is Optionally an alternative URL by which this term can be accessed. Use a relative path and don't add a trailing slash or the URL alias won't work. We will see relations later just save the term.
- Add some more terms to this vocabulary, let's say "Business Articles", "Financial Articles", "Regional Articles", "Movie Articles".
- Once you finish adding terms click on List tab as shown in above page to access list of terms under "Article Type" vocabulary. You will see screen like below.
- As shown in above screen, you can any time edit any term using edit link next to the term. If you want to order terms use the drag & drop functionality. Be careful while drag & dropping if you drag to right terms will become child of top term, which will create hierarichal terms which we will discuss in next tutorial. Drag down to change order. After doing changes click on save button to save the order.
- Now it's time to associate our content type Article with this vocabulary.
- To do that, we need to add a term reference field to article content type. Login as administrator >> Click on Structure link on top black menu bar >> Click on Content Type link >> Click on Manage Fields link next to article content type to access below screen.
- Create a new field of term reference type as shown above and click on save button. You will be redirected to next screen where you need to select vocabulary. Select vocabulary as article type and click on "Save Field Settings". Now you will be redirected to another screen as shown below where you can have some more settings related to term reference field.
- All the settings are explained in above screen. Make necessary changes and click on save settings button. Finally, we finished associating a vocabulary to a content type.Its time to add some articles and classify them into various categories.
Adding articles and classifying them using Term Reference Field:
- Add a new article content. To do this Click on "Content" Link in black menu bar >> Then "Add Content" link >> then "Article" to access screen like below.
- Create a article and select Article Type as Business Article. If you want to associate more than one category then separate them by comma.
- Repeat above step to create 3 - 4 different articles with different article types.
- Now access any article that has article type associated with them. You will see something like screen below. You can notice the article type category links are appearing on the node page.
- Now if you click on term links for example sports articles you will be redirected to page like some thing below which will list teasers of all articles which belongs to sports articles category. This way using taxonomy concept we can categorize drupal contents.
- Finally, we learnt how to create vocabulary, how to associate vocabulary to content type, how to add terms, how to associate terms to nodes and the taxonomy concepts in Drupal 7.
Stay tuned with me to learn advanced taxonomy concepts like hierarichal terms, taxonomy fields in drupal 7 and new taxonomy features introduced in Drupal 7 in my next post.
Comments & Suggestions are welcome on tutorials :-)