List user’s comments on a user page tab

As site member, I would like to view my own comments on a tab on my user page. I would also like to be able to list comments written by other users on their user pages. This is important since it helps me find my own comments, follow what other people comment, and also get an overview of a user’s contributions.

How to Demo: 
  1. Log in to the site.
  2. Write two comments.
  3. Visit the user account page and click on the tab Comments. Verify that the created comments are listed, with newest on top.
  4. Log out. As anonymous visitor, visit the same user page. Verify that the comments tab is visible and lists the two comments.
Required Preparations: 
  • The site should have the documentation page and collection content types, as provided by the first exercise in this suite.
Additional Comments: 
  • It makes sense to limit the comment list to display comments only for nodes the user is allowed to view. This can be done using the content: accessible filter – however this feature is at the time of writing not fully functional.
  • In future versions of Views, it is possible that you will need the relationship comment: author to add the contextual filter on user ID.
  • The user story does not define how the comment list should be displayed. Defaulting to standard comment view mode is a quick solution, that can be changed in a future user story if the client would like a different list.
Modules: 
Downloads: 
AttachmentSize
2.85 KB
Suggested Solution: 
  1. Create a new view, displaying comments, newest on top. Create a page with the path user/%/comments, displaying full comments (not fields). (See creating new views in the previous chapter.)
  2. Add a new contextual filter, comment: uid. Set the title override to comments by %1, and also validate that the provided filter value is a valid user ID. (See configuring contextual filters in chapter 10.)
  3. Set the menu settings to a menu tab with the link text comments. (See creating menu tabs in chapter 10.)
Solution Video: