0

Working with views and a taxonomy list is a popular subject at DA. Many of the examples I've found refer to making a jump list of taxonomy terms and parent terms similar to what you may see with a nested vocabulary on your site's core taxonomy page [1] (following the list terms link on any given vocabulary). My Views view goal is just as simple and I'm nearly there except for two important requirements.

My Views view is a catalog of node content titles and truncated descriptions categorized by a two level vocabulary. (Think of finding something at a hardware store). The goal is a single page without a sorting requirement (think of it as a very small hardware store, so I skipped the answers suggesting wild card sorting in the URL). I'm nearly there using the table format where I've used the setting Groupping Field Nr. 1: Content: My_Taxo to organize the node content. This creates a separate table for each group and a caption element for each category.

The first missing requirement is the parent term.

The instructions for a simple vocab list say to add the Relationship, Term parent. This adds several new items to Fields: add list page. Unfortunately, none in this list are distinguished as parent term, which means I can't easily add a parent taxonomy term field, add a child term field, go back into Table: Settings set Groupping Field Nr.1 to be the parent and Nr.2 to child and be done with it. (9_9)

  • Content: All taxonomy terms
  • Taxonomy term: Name
  • Taxonomy term: Rendered Taxonomy term
  • Taxonomy term: Term description
  • Taxonomy term: Term edit link
  • Taxonomy term: Term ID
  • Taxonomy term: Weight
  • Taxonomy vocabulary: Description
  • Taxonomy vocabulary: Machine name
  • Taxonomy vocabulary: Name
  • Taxonomy vocabulary: Vocabulary ID

The second missing requirement, which may only be correctly answered by the first problem, is the captioned tables do not sort in the same order as the weights set on the taxonomy page list. To try to set this requirement I added, Sort criteria: (menu_category) Taxonomy term: Weight (asc)


1 Answer 1

0

Starting from scratch with a dummy content type that contains just a title and a taxonomy term.

1) Create the simple taxonomy: Category_hierarchy {i.e. 1, 1.1, 1.2, 2, 3, 3.1};

2) Create the simple content type. {title, taxonomy [Category_hierarchy];

3) Create the view:

Format: Table
+ Settings
- Grouping field Nr.1: Category_hierarchy

Fields
+ Content: Title
+ Content: Category_hierarchy
-- Exclude from display.

Sort criteria
+ Content: Title (asc)

Relationships
+ Content: Taxonomy terms on node [1]
-- Vocabulary: Category_hierarchy
-- [custom] Identifier: Category_hierarchy_child

[1] This is the only taxonomy-type Relationship available.

Results show the node titles grouped by the child relationship as expected.

4) Revisiting the View now that we see what we can simply construct, we try to get the parent term added to the display. Now, under the Relationships section is a whole new list of options titled "Taxonomy term". So we add one more to get the missing relationship, parent.

Relationships
+ Taxonomy term: Parent term
-- Relationship: Category_hierarchy_child
-- [custom] Identifier: Category_hierarchy_parent

If we peek into Table's settings, we would hope this might make the new relationship an available option under Grouping field Nr.1. But the grouping field options are still only Category_hierarchy and Title.

Just to be sure I added Grouping filed Nr.2 with Category_hierarchy to see if Views can do something magical and sort out the relationships automatically.

Nope. But it was worth a try. Its clear there must be some other way to populate that menu. Maybe Views has made some kind of magical field we can add from under Fields?

And that's just what has happened. We now have a new type of available field, 'Taxonomy term':

Taxonomy term: Name
- The taxonomy term name.
Taxonomy term: Rendered Taxonomy term
- The Taxonomy term of the current relationship rendered using a view mode.
Taxonomy term: Term description
- The description associated with a taxonomy term.
Taxonomy term: Term edit link
- Provide a simple link to edit the term.
Taxonomy term: Term ID
- The tid of a taxonomy term.
Taxonomy term: Weight
- The term weight field
Taxonomy vocabulary: Description
-The taxonomy vocabulary description
Taxonomy vocabulary: Machine name
- Machine-Name of the vocabulary a term is a member of. This will be the vocabulary that whichever term the "Taxonomy: Term" field is; and can similarly cause duplicates.
Taxonomy vocabulary: Name
- Name of the vocabulary a term is a member of. This will be the vocabulary that whichever term the "Taxonomy: Term" field is; and can similarly cause duplicates.
Taxonomy vocabulary: Vocabulary ID
- The taxonomy vocabulary ID

I've crossed out the unlikely candidates. And added each, in turn, to the Field section and looked for the field in Table's settings. Good gravy. They both worked!

I certainly don't expect tutorial answers. But I was already writing up a bug report for another problem I encountered so, my bug is your gain.

Your Answer

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

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