Looking for a solution in working with grouping with Drupal views? Trying to group content items and group according to class or some classifications or in Drupal is called grouping content items by taxonomy terms.

 

What is Taxonomy?

Taxonomy is used to classify website content. Taxonomy terms are entity types and the entity subtypes are the vocabularies. Like other entities, taxonomy terms can have fields attached. If you use them to classify regular content items, your site will automatically be set up with taxonomy listing pages for each term.

 

Individual taxonomy entities are known as terms (the blog tags or recipe ingredients in these examples), and a set of terms is known as a vocabulary (the set of all blog post tags, or the set of all recipe ingredients in these examples).

 

An example of grouping with Drupal views; content items with different fields, title, date of publication, data, etc.

drupal-views-content-items.png

 

 

Each of these content is grouped according to their classifications or category or taxonomy terms and we need to group this according to some sort of sorting by grouping field or sorting by groups.

Steps on how to create a simple grouping using Drupal. 

  • First, login into Drupal 9. We have previously created a content type called policy we have  all those and, 

drupal-views-content-type-policy.png

  •   In a separate area, we also created under structure a policy category or vocabulary which will group or categorize all these contents accordingly. We have created all these terms under a taxonomy vocabulary called policy category.

drupal-views-structure-taxonomy-policy-category.png

  •  Once we have that we would head over to views because we would want to create initially a simple listing of all those policy content items.

drupal-views-go-to-views.png

 

  • Create a views page, we’ll call this a policy test. This will become the listing page similar to what we have here for all the policy content items, of course, you would want to get the content that is from the content type policy only and we wouldn’t want to sort it yet we’ll do that later on by obvious.

  • and then we create a display page for this view 

  • and then we’ll simply immediately create a URL so that we can access it by URL later on in a quick manner.

drupal-views-view-basic-nformation.png

  • At this point, we’re going to utilize a table view, a table format, and a table display. The pager will still default. And there’s still no block yet just a page that is accessible by a policy/test URL.

drupal-views-table-view.png

Now we have this simple listing or a simple table. A table that contains all of the content items that are created as policy content items. 

drupal-views-simple-listing.png

Simple Listing

drupal-views-simple-table.png

Simple Table

 

This filter criterion is the first few steps that we did earlier when we were creating this display page or these views page. The first thing that you would notice probably is that the table simply lists all the titles of the content item. The reason is that when we were creating the views we created by default a display page that will get the title of those contents.

In adding more information such as the date when it was signed, when it was probably published, and such, those are all appearing under the policy content type watch the full video tutorial here: