As site member, I would like to be able to flag other users as friends. I also want a tab on my user page with a list of links to all my friends’ user pages. This is important since it helps me staying up to date with contributions from people I like.
- Log in to the site.
- Flag two users as friends. (Create the users first, if necessary.)
- Go to your user page and click the “Friends” tab. Verify that the flagged users are listed, in alphabetical order, linking to the respective user page.
- A standard Drupal site.
- This could be implemented as a tab found on each user page, or merely a tab where you see your own friends. The latter would be difficult to do with Views and Flag only, but quite easy in combination with Page manager.
- If a user hasn't flagged any friends, it makes sense to have a short text displayed in the view – see a few more basic Views settings for information about how to do this.
- If you want more challenges, you can also create a list of all users who have flagged the viewed user as friend.
- Add a new user flag. Give it the machine name flag and the title friend flag. Add descriptive flag/unflag texts, descriptions and confirmation message. (See configuring flags in chapter 11.)
- Allow all authenticated users to use the flag, but not to flag themselves. (See configuring flags.)
- Add a new view. Give it the name friends to a user, and have it list users. Create a page with the path user/%/friends and display an unlimited number of items in an HTML list. (See creating new views in the Views basics chapter.)
- Sort the view by user name and add a menu tab with the text friends. (See configuring sorting in the Views basic chapter and creating menu tabs in the advanced Views configuration chapter.)
- Add a new relationship flags: user flag to join flag information to your view. Restrict the list to only flagged users, but users flagged by any user (not only the current user). (See combining Flag and Views in this chapter.)
- Add a new relationship flags: user to join information about the flagging user to your view. (See combining Flag and Views.)
- Add a contextual filter user: uid and make use of the relationship to the flagging user – to require that the flagging user has the user ID specified by the contextual filter value. (See combining Flag and Views in chapter 11, plus configuring contextual filters and utilizing relationships in configuration in the advanced Views configuration chapter.)