0

I have a taxonomy field in the user registration form called location, I have a view listing all location terms (taxonomy terms).

I'm having trouble linking the terms to a view (containing the users info based on the location term), when the taxonomy term is clicked in a list of all terms, to display users that have the taxonomy term (with the same location). By default the taxonomy term view is set to display content and I'm having trouble changing that to display users.

4
  • How can we reproduce this issue? Please edit your question for clarification.
    – leymannx
    Apr 12 '20 at 10:19
  • I've tried to explain further. What area don't you understand me? Apr 12 '20 at 10:34
  • In View settings, under advanced, add a telationship of location to your View, that will give you access to add user fields, if that's what you're asking.
    – No Sssweat
    Apr 12 '20 at 15:44
  • @NoSssweat, Thanks I did that the issue is I want to create a list view of all the taxonomy terms whe clicked they are linked to this view. When I click currently still goes to the taxonomy term view which can't display the users Apr 12 '20 at 16:29
1

You can create a View or Views with pages to accomplish this. The presentation of nodes connected to a taxonomy term on its display page is baked into Drupal separately from Views, I think. I'm not positive about that; I never use it. I'm more likely to go around it for reasons similar to what you're describing.

One page can easily present a list of of your location taxonomy terms. I would use a field-based view, and show the name of the term from the list. Uncheck the box that has the field link to the term directly, and instead check the box for the field to function as a custom link (under "Rewrite Results"), put in some URL that will include the location name, e.g., /user-location/{{ term_name }}. Scroll further down and you'll see "Replacement Patterns". Use what seems appropriate there.

The other page may be field-based or entity-based dependent on your specific needs. It keys off users, and makes use of a contextual filter. That contextual filter is the location term name taken from the URL. The page URL will use the one you set in the first page. Thus this page will present user info filtered by the location term.

5
  • HI, Thanks for the response i think the issue is with creating the link so it should be user-view/{{ term_name }} exactly? Apr 13 '20 at 0:02
  • You want use whatever the twig suggestion is for the field. You'll get a list of available information when you play with the settings. Everything should match between the link of the one page and the contextual filter of the other.
    – beltouche
    Apr 13 '20 at 0:11
  • OK thanks, Sorry I'm a bit new how do i get the twig suggested name? Apr 13 '20 at 0:32
  • Added details for finding replacement patterns in the answer
    – beltouche
    Apr 13 '20 at 0:41
  • Thanks man! worked Apr 13 '20 at 0:47

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.