In this video, I will show you how to create a view that show each user their own bookmarks.
- Go to "Structure => Views => Add new view" (admin/structure/views/add)
- View Name: My Bookmarks
- Show: Choose "Content" of type "All" (Even though we’re showing all, we’re only going to show bookmarked content. Right now, we can only bookmark Articles, so that’s all that will show up. But, if we added another content type later, settings this to “All” will allow that content type to automatically show up in our view at that time.)
- Sorted by: "Newest first"
- Select "Create a page"
- Page title: My Bookmarks
- Display format: Unformatted list
- of: fields
- Items to display: (Clear this to display all items)
- Uncheck “Use a pager”
- Select "Create a menu link"
- Menu: Main menu
- Link text: "My Bookmarks"
- (Continue & edit)
- Advanced
- Click "Advanced"
- Relationships: Click "Add"
- Select
- "Flags: Node flag"
- Select
- (Apply (all displays))
- Configure Relationship: Flags
- Identifier: flag
- Select "Include only flagged content"
- Flag: Bookmarks
- By: Current User
- (Apply (all displays))
- No results behavior
- No results behavior: Click "Add"
- Select "Global: Text area"
- (Apply (all displays))
- Label (Textarea): You have not yet bookmarked any content. Click the "Bookmark this" link when viewing a piece of content to add it to this list.
- (Apply (all displays))
- Page Settings
- Click "View published content" link
- Permissions: Choose "Flag Node entities as Bookmarks"
- (Apply (this display))
- Click "View published content" link
- (Save)
Now, if we go to our home page and click "My Bookmarks" on the navigation menu, we’ll see the “No results” message we just configured. In order to test the bookmark flag, I’ll create some articles with Devel Generate.
- Go to "Configuration => Development => Generate content" (admin/config/development/generate/content)
- Check: Article
- Uncheck: Basic page
- How many nodes: 10
- (Generate)
Now I’ll go home and click "Bookmark this" next to the first article. Now, we can click on "My Bookmarks" and see the article is now included on our list. And if you click on the title, you can view the article.
You’ll also see the “Remove from Bookmarks” link. If I click that, when I go back to the “My Bookmarks” tab, you’ll see that it is no longer in my bookmarks.
And just to show you that the “My Bookmarks” view is unique to each user, I’ll log in as another user in Safari, and bookmark the first article.
Now we’ll move on to using the Flag module to flag content as offensive.