0

In Drupal 7, the module taxonomy_display allowed me to insert a content view via views display options under the taxonomy manage display. I am working on rebuilding my Drupal 7 views for Drupal 8, and the way they are built in 7, they depend on this function.

We are using a (term) view to display parent terms as links to navigate to:

  • either a child term view (parent/% path) displaying child terms as links to the content view when the content is ascribed to the child term.
  • or our content view (also parent/% path) when the content is ascribed directly to the parent. We accomplish this in our content view by using no results behavior/global view area to inject the child term view when there is no content ascribed.

With the taxonomy_display module, you then simply go to the term page display and set that to the content view. It will show child terms when there is no content ascribed, and it will show content when there is content ascribed.

enter image description here

The module documentation for taxonomy_display for D7 says that the core function of this has been included into Drupal 8, and refers you to this issue for more information, but there I didn't find information there on how this function is implemented in Drupal 8. It seems that they are referring to the taxonomy/term view in now in core.

My question is, can i still accomplish this structure without the taxonomy_display module merely by what is provided by the taxonomy/term view in core?

Or can I ignore the taxonomy/term view all together and accomplish it a better way? I'm new to D8, so any help would be appreciated!

  • It seems that module is only allowing for configuration to happen on the term configuration. I don't see why anything except that couldn't be recreated through Views. It would take some more steps and more effort, but in the end the users won't notice the difference, it's only a bit more convenient for the admins who are configuring the terms. Core comes with "Taxonomy term" Views that apply to all Vocabularies equally. You can modify them and override so that each Vocabulary has its own settings. What features exactly do you think you're missing from the Taxonomy display module? – prkos Jul 26 at 17:14
  • I edited the post to give our use case, and clarify my question. – TonyTheFerg Jul 26 at 18:23
  • 1
    One way to do this, which I do on my projects, is I disable the term View so the control is delegated back to the entity view level. I add fields on certain Vocabulary, and theme it in the twig file (taxonomy-term--full.html.twig). You could preprocess it for greater control over what shows. If you want different terms and vocabulary to show different Views, you would want to look at a module like TVI. – Kevin Jul 26 at 19:06
  • Thanks for the suggestion on TVI! – TonyTheFerg Jul 26 at 19:46
  • Copy and paste that in the answer and I'll give credit where credit is due! TVI is better than what I had going on, and got the job done! – TonyTheFerg Jul 26 at 19:54
2

Both of the modules mentioned (Taxonomy display and TVI) that make Taxonomy term pages easier to configure rely on Views, so you do need to have the Views sorted out before you can assign different Views to different Vocabularies. These modules don't replace the "Views magic".

If you don't use these modules that override how term pages are displayed the "Taxonomy term" Views that comes out-of-box handles all of the terms equally. BTW "Taxonomy term" Views is of the content type (not the taxonomy term type, the name can be confusing a bit).

But the "Taxonomy term" Views can be changed to handle different Vocabularies differently. This change can be made in the Contextual filter in the validation settings. Then you can clone that page, give it a different path, and adjust the contextual filter validation to a different Vocabulary.

Both of your cases can be handled with the modified "Taxonomy term" views. Using the "Summary" option in the contextual filter for the Taxonomy reference field will list the terms present in the views results. When you click through those links you see the content listed. Although your "No results behavior" solution also works.

You can get the Parent info into your path through another Contextual filter (Taxonomy Name), that you can get after adding the Relationship for the parent term in your Views.

It's all in the Contextual filters and perhaps some Relationships to create your cases. There are a lot of answers here relating to those so you can search and learn from them.

It is also mentioned in the comments you can use the theme templates to override how Term pages are displayed, when you're not using the Views to build those pages, but you'll probably still use Views to build blocks to put in those templates, unless you know SQL and can create better queries manually.

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.