0

I am trying to create a view where I have the same taxonomy term for a node and profile to link the two together. Here is what I did:

I created a profile with a taxonomy(Current Company) with a value of: company1

I create a node with a taxonomy(Current Company) with a value of: company1

I created a user view and created a relationship to see all content. This works but I tried to create a filter where the logged in user profile (company1) = the value of the node taxonomy (company1).

So basically since the logged in user belongs to company1 he only see content related to company1.

I have been trying different combinations and cannot get this to work, I know it has to be possible.

Thanks

2 Answers 2

0

You can use relationship settings to add in the taxonomy, and then add a contextual filter on "user:uid" with taxonomy value fetched from currently looked-in user.

Have a look at this refrence: https://drupal.org/node/1111722#comment-4315620

Copied here in case that node goes away:

  • Create a user view.

    Add a contextual filter on user: uid. If no filter value is present, build a default value using the currently logged in user. (This will give you exactly one user object in your view -- the logged in user.)

    Add a relationship, using the relevant taxonomy reference field on the user accounts. This will bring you information about the "interest" term for the logged in user.

    Add another relationship, called "term: nodes marked with term" (or something like that). This will bring you information about all nodes marked with the interest term for the logged in user.

    Either set the view to display node teasers, or select a number of fields to display.

    Add a display as usual. Done!

1
  • I tried this one already with no luck. Commented Sep 4, 2013 at 20:30
0

I solved this problem by adding a Contextual Filters > select Current Company > select Provide default value > then selected Type - PHP Code and added this:

global $user; $user_fields = user_load($user->uid); $profile = profile2_load_by_user($user_fields, 'main'); return $profile->field_my_company['und'][0]['tid']; 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.