List user's content on a user page tab

09.14_posts_by_user.png

As site member, I would like to have a list of all the content I’ve written available as a tab on my user page. I would like similar tabs on other users’ pages. This is important since it helps me keep track of my own contributions as well as following what other members write.

How to Demo: 
  1. Log in to the site.
  2. Create a documentation page.
  3. Visit the user account page and click on the tab “Posts”. Verify that the documentation page is listed.
  4. Create a documentation collection.
  5. Verify that the documentation collection is listed, too, and (since it is newer) is listed above the documentation page.
Required Preparations: 
  • The site should have the documentation page and collection content types, as provided by the first exercise in this suite.
Additional Comments: 
  • You may or may not have to add the relationship in step 3 in the suggested solution – it depends on how the Views module is changed the next few weeks. (Normally, content authors are automatically available in a view of nodes, but this may change.)
  • Whenever you have a view using contextual filters, you should have the view returning page not found if contextual filter value is missing – unless you have reasons to do otherwise. This prevents the view from being used in unexpected contexts.
  • The user story doesn't say how the content should be displayed. A teaser list is easy to make and usually pleasant to look at – changing it to a table, for example, can be made in a future user story if the client would like to change the appearance of the list.
Modules: 
Additional Resources: 
Downloads: 
AttachmentSize
documentation_site_09.zip2.8 KB
Suggested Solution: 
  1. Add a new view with the name content by user. Have it display content of all types, sorted with newest on top. Create a page with the path user/%/posts, with a list of 10 teasers per page, and no menu link. (See create new views in the Views basics chapter.)
  2. In the main configuration panel, add a menu item of the type menu tab and give it the link text posts. (See creating menu tabs in advanced Views configuration chapter.)
  3. If the contextual filter user: uid is not present, add a new relationship content: author. (See adding relationships in chapter 9.)
  4. Add a new contextual filter user: uid. Use the title override option to set the title to content written by %1. Use the validation options to verify that the contextual filter value is a user ID. (See configuring contextual filters in chapter 9.)
Solution Video: 

Add comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.