Drupal Answers Asked on January 30, 2021
I have a hierarchical taxonomy like the following:
The body text of content1, content2, … of a content type will go under the terms term1, term2, ….
Can you kindly help me in getting the view with the following structure?
A simplistic one page approach:
The instructions will be slightly different terminology for Drupal 8 and Drupal 7. Below is one way to get it done in Drupal 8
Create a new view of content, set to the "type" that you mentioned above. Select page, and set the page display setting to your desired format, of: fields. Add the content body to "fields" , as you mentioned you wanted to display the body. Also add "Bachelor Degree" Content field to grab the Bachelor degree vocabulary. Click exclude from display, as this field is only there to grab the fields for grouping. You can also deselect link label to the referenced entity if you like.
Under the Advanced tab - add relationships, add Taxonomy term referenced from field_bachelor_degree so that you can add that relationship to what will be your term parent field.
You can now go back to fields and add the parent term taxonomy field, and use the relationship you just created. Click exclude from display, as this field is only there to grab the fields for grouping. You can also deselect link label to the referenced entity if you like.
Then under format settings use grouping fields to display the content under the term headers in your (content) view. In your case, grouping field nr. 1 should be the taxonomy term name related to parent term, and grouping field nr. 2 should be the first content taxonomy term. See second photo. Note: The second grouping field will only become available after saving the first one. You can then use Sort criteria how you want it (probably ascending).
Also, if your content type contains content not related to this view, you can add/change your filter criteria to only show the "Bachelor degree" vocabulary.
This method should do the trick for Drupal 8. I have provided a screen shot of the Drupal 8 view, the grouping fields, and the result of this below.
If you were asking for a complex paging solution, I have that too, but I removed it from this answer to make this answer more concise.
Answered by tonytheferg on January 30, 2021
You would use /taxonomy/term/% - which is a default view, you don't have to create it. The view should show Fields of body content or whatever other fields you you have associated with the node that you wish to display. Your content types also need to have fields where the correct taxonomy categories can be selected when creating the node. Your view "Sort" and "Filter" criteria will determine how these nodes are ordered.
To preview your view, use /numerical term ID of your taxonomy term
To get your nodes to display, create a menu with the same parent-child structure as your taxonomy terms and set the menu paths as the taxonomy term ID. You would then display this menu as a block either on a page or in a sidebar.
Answered by Niki on January 30, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP