2

I have a term reference field in my user accounts and I have nodes that are also tagged with that same vocabulary.

I have a view set up to display all the nodes, but I want it to display only nodes that have the terms that the users has checked in their account.

Example:

Node: Shirt
Term(s): Blue

Node: Skirt
Term(s): Green, Blue

Node: Dress
Term(s): Red

Node: Shoes
Term(s): Purple

My user has terms: Blue, Red

I would like to see nodes: Shirt, Skirt, Dress

0

One of the possible solution can be

  • Create a view to show the nodes with contextual filters as taxonomy,remember to allow multiple taxonomy terms may be separated by '+' in the contextual filters.
  • Create a custom menu item in your custom module and in the page callback of which grab the taxonomy terms in the global user object and call the above created view programmatically.

  • Here is a snippet showing how you can call your view programmatically with contextual filters.

    views_embed_view("your_view_name", "your_view_dsiplay", $taxonomy_terms_+_separated),
    
  • Thank you for the tips! This is getting me somewhere... it even might work as a fixed value with php in the contextual filter. The one thing I'm having trouble with now is the use of multiple filters. When I pass multiple (either with comma or plus), it only uses the first and brings up the corresponding node. Any idea why it won't listen to using multiple? I've also tried with and without the validation with the taxonomy using the term IDs. No change. – Deez Sep 25 '13 at 17:25
  • You have to set in the views to allow to have multiple taxonomies,I do not have my PC with me right now otherwise I would have added a screenshot – arpitr Sep 25 '13 at 18:16
  • I think I do have it set that way... For "When the filter value is NOT available" I have "hide view", "When the filter value IS available or a default is provided" = "Specify validation criteria / Taxonomy Term", and then I have the vocab selected and "Filter value type" is "Term IDs separated by , or +" – Deez Sep 25 '13 at 18:24
  • Did you check passing the multiple taxonomy terms in the preview down below in the views to debug – arpitr Sep 25 '13 at 18:25
  • Yes, I tried it in the preview and it only listens to the first ID. So if I swap the order, it will listen to the order, but never both. – Deez Sep 25 '13 at 18:27
0

Hers goes screen-shot.

  • Note: In my test installation I have created taxonomy terms test1(tid = 1),test2(2),test3(3),test4(4) and created 4 nodes as node1,node2,node3,node4. node1 has test1(1) has tagged term, node2 -> test2, node3 ->test3, node4 ->test4.

    1. A view page showing node listing as the taxonomy ids present in the url enter image description here
    2. Down below goes my views configuration image by image for contextual filters. enter image description here enter image description here enter image description here
  • facepalm Thanks for that... I was missing the very end. Thanks for your time! – Deez Sep 25 '13 at 20:06
-1

If I understand your question correctly, you want to setup a relationship to the taxonomy term and then to the user. You "may" also to to add a contextual filter for the current user, but I'm not sure, however, the relationship should help.

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.