1

I'd like to create an HTML sitemap viewable by a human. I mention that I'd like to keep the hierarchy (tree structure of categories with subcategories) like the following:

- TERM_A
  - Node a
  - Node b
- TERM B
  - TERM_B1
    - Node c
    - Node d
  - TERM_B2
    - Node e
    - Node f

For example, is it possible to display the results as grouped categories and sub-categories, by managing the order or results (relate to taxonomy term, sort by term weight and nesting level)?

2

You can do it using the grouping fields feature inside Views.

Create Views listing your nodes (titles), add a Field showing terms they're tagged with (sub-term).

Then add a Relationship for that same Field (the Taxonomy term reference Field). Add another Relationship to introduce Parent term, use the first Relationship here.

Now add another Term name Field and set it to use the second Relationship, this way the Field will show the first level Taxonomy hierarchy for a node.

Now edit your Format settings and set the Grouping field Nr.1 to use the Parent Field, and set the Grouping field Nr.2 the usual (sub-term) Field.

If you need further control of the output you can overwrite to change HTML, and use CSS to emphasize the hierarchy visually.

  • Interesting approach. However if TERM B contains nodes, TERM B appears two times: one time with its nodes, and second time with its subterms and their nodes. Would you have an idea to avoid that and make it grouped? – Kwadz Sep 17 '18 at 8:51
  • To exclude nodes that are tagged with only Parent term would be easy, but to group them with subterm nodes in a hierarchy is a bit tricky. Try the Views tree if it works with D8. Depending on your approach this module might be relevant: Views Taxonomy Term Name Depth. If all else fails use Views Field View to insert one view into another (child nodes View into Parent terms with nodes View). – prkos Sep 17 '18 at 19:12
0

Have you looked into the XML Sitemap module?

It creates a sitemap page for you and it comes with XML Sitemap Taxonomy as a submodule that you can enable and configure.

If you want to reorder the way they appear, I'd assume you would edit the taxonomy itself and have that reflected in the sitemap output.

  • Thanks, but I'd like to create an HTML page, not an XML page. This module can create XML pages only. – Kwadz Aug 30 '18 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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