I can easily set up views that show nodes and related notes flagged by the current user, but I'm having a really hard time listing notes that were flagged by an arbitrary user. Here's my use case:

On the user profile, there's a new tab, "Bookmarks." That tab is provided by Views, and shows the user's bookmarked nodes (path: user/XX/bookmarks).

My view is set to use the User ID from the path as a contextual filter (argument), and I tried setting up some flag relationships to display nodes flagged by the user ID in the path, but I can only get the view to show nodes flagged by the current user (the user viewing the view).

I found #875726: Display nodes which were flagged by user you follow for 6.x-2.x, but that references a default view which is not available for the 7.x branch of flag.module...

Can I set something like this up in 7.x, or is this functionality not available?

Comments

geerlingguy’s picture

...in that issue, vegeneric commented:

I had totally overlooked how the double relationship + argument setup was working in that view.

However, I can't figure out a way to do this :-/

ShadowMonster’s picture

Go by this tutorial: http://drupal.org/node/326580 you need set it similar for users.

geerlingguy’s picture

Status: Active » Closed (works as designed)

Okay, it looks something like this, then (thanks for the link, ShadowMonster!):

  1. Add the 'Flags: [flag type]' relationship, and set 'By' to 'Any user.'
  2. Add the 'Flags: User' relationship; don't set any options for it.
  3. Add the 'User: Uid' contextual filter, and set it to 'Provide default value' 'User ID from URL'.

This will allow you to display content flagged by a given user, based on the UID value in the URL, like at user/[uid]/flags.

Works great, but takes a bit to wrap my mind around the relationships and how they interact with the views query! I didn't think to add two flag relationships...

I've added a comment to http://drupal.org/node/326580, though that documentation is for 6.x...

arlingtonvoicellc’s picture

#3 works great in Drupal 7! Thanks!

siva.thanush’s picture

Issue summary: View changes

How do I make it work for anonymous user.
I am using Session API for the anonymous user to come and flag in my site.
But how Do I show him the node he has flagged for this session.

hubert_r2’s picture

Is there a way to achieve this with a view created from a search API index?

All the relationships/contextual filters describe in #3 (which work great for a regular view) don't seem to be available with a search api view...