Note: This is a follow-on question from Creating a displayable 'index' of content nodes within a path

Ok, starting to find my feet again within Drupal, and still getting up to speed with views.

What I'm needing help with

  1. How do I update my view for /documentation, to display the results in a proper HTML ordered and numbered list that follows the taxonomy structure? (i.e. 1. SOP, 1.1 HR and People, 1.2 HACCP, and so on)
  2. How do I then easily duplicate the view's functionality to the L2, L3 and beyond, so this kind of display runs at every level of the taxonomy when it is accessed - i.e. /documentation/hr-people, /administration/fleet/maintenance etc. Does doing this require a content view to be created for every single level/tree in my Content zone taxonomy (which I would think is cumbersome and laborious), OR is there a way to have only a single view with the intelligence to know what page it's being run on within the taxonomy and only display the relevant results at that level?

(I hope the way I've framed this question and the supporting materials below make perfect sense)


Following on from the assistance of Hodba Khalaf, I've been able to create my documentation taxonomy (called content zone) for my site, which looks a little something like this:

My current taxonomy

I've also been able to create a View (called Content zone), targeting the Content zone taxonomy:

My view configuration

This works fine at L1 (/documentation) - with the exception that I'm not entirely sure how to make display the resulting information in an ordered and numbered list relevant to how the taxonomy is laid out, rather than the alphabetical order in which it is displayed.

L1 view of /documentation

And from there, clicking on one of the links for a L2 within my taxonomy (say /documentation/marketing) will show all the content assigned to that L2 within the taxonomy; but won't show the L3 headers and links (i.e. /documentation/marketing/advertising, /documentation/marketing/email-waf) of the taxonomy associated with the L2 of Marketing

L2 view of /documentation/marketing

I hope what i'm trying to achieve has made sense, and appreciate all and any help to point me in the right direction for achieving this.

1 Answer 1

  1. There are features in Views concerning taxonomy hierarchy, displaying terms with depth, you should look into it. There is also Group by field option under Format in Views where you can, for example, group by Parent field (Parent of the Taxonomy term). You may need to add a Relationship for the Taxonomy field first before you can see those extra Fields/Filters. Contextual filter with depth might also be useful.

  2. You should look into displaying Menus with depth, since each Taxonomy Vocabulary already has a Menu block. You can learn more about it here: Primary and Secondary Navigation in Drupal 8

Generally speaking, you want to get to a point where you have correctly nested HTML list items. Then you can use CSS to adjust the numbering to go into levels 1.1, 1.2 etc.

Or if that numbering is so important you could add a field for it on your Vocabulary, so each item has that textual bit of data associated with it (not numbers because the sorting won't be correct, you want 1.10 > 1.1). Sorting in Views can still be done with the term weight (the sorting you saved in Taxonomy).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.