Showcase a User's Comments with Views and Menu Tabs

Published August 27, 2009

By now, you should know and love the Tracker module that comes with core. It has its strengths, but many weaknesses. For one, you can't separate out posts from comments, or sort the list in interesting ways. Views can help you make exactly the list you want, and place it in a tab on the user's profile exactly like the "Track" tab.

For this example, you'll be adding a list of comments. Creating the view is simple enough:

  1. Clone the default view comments_recent, and call it comments_by_user
  2. On the Page display, add a Relationship for Comment:User
  3. Add an Argument for User: UID and choose Relationship: User (assuming you did not re-name the realtionship)
  4. Before saving the Argument, set the Action to take if argument is not present to be "Provide default argument", then choose "User ID from URL"
  5. Change the page's Path to "user/%/comments"
  6. Give the page a Menu entry by clicking the text that says "No Menu" and choose "Menu Tab", then name the tab "Comments"
  7. Make sure you save the view
  8. Visit any user's page, and you should now see a "Comments" tab next to "View"

For more information about creating views with Relationships, read Mike's article.

Comments

I was just boggled trying to find the UID argument on a comment view and turned to Google, which brought me here. Working great, now, thanks. :)

Michelle

Submitted by Guest (not verified) on Thu, 09/10/2009 - 22:47

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!

Name
CAPTCHA