The S-Files: "A view that displays a user's content"

UPDATE: I think this recipe is deprecated by the Views Attach module which addresses the use case directly: http://drupal.org/project/views_attach
Tech Support Case Studies
My duties at Acquia include answering the phone when European clients call needing support. Today I helped someone who needed a way for their site users to be able to find the content that they had authored. The recipe I suggested involves making a view that displays all content filtered by a particular user id. By having the view provide a block display you can then put that block on the user's profile page and they always have a place to go to find the latest content that they've created.
I provide an outline of the steps for this view below, but if you are in a hurry you can download the exported view and import it for yourself. You can also download a PDF file of all the screenshots I made while creating the view.
- Create a new view. The base table should be nodes.
- I modified the display to be HTML list values. I then added the title and type fields. The display and fields you choose, however, can be whatever you need. This is totally up to your needs.
- I added an argument. Arguments are bits of information that come in via the URL (path) which tell the view how to filter. In our case we want the view to filter on the user id, so we have to add a User: Uid argument.
- The trickiest part of this whole tutorial is how to configure the argument. See page 10 of the PDF for a screenshot. It is important that you choose the option "Action to take if argument is not present: Provide default argument." This is because we're creating a block view, and block views don't automatically take arguments from the URL like other views can. Thus we assume the argument is not present and provide it manually.
- Fortunately there is a complimentary option "Default argument type: User ID from URL." That is just what we need! Now the view will know that the integer present in the URL is to be interpreted as the user's id, and that it should use that number to filter the view.
- I then added a block display to the view, and saved the view. Don't forget to save the view!
- Now it's time to configure the block to appear on the user's profile pages.
- Viola! All done.

Acquia helps you succeed in building your websites by providing expert technical advice and support.
| Attachment | Size |
|---|---|
| content-by-user-view.pdf | 1.13 MB |
| content-by-user-view.txt | 1.86 KB |
Related Content
AcquiaBlog

2010 has been an inflection point for the Acquia partner program. We are doing more business than ever with partners, including case studies with Palantir.net, Blink Reaction, and IBM Global Services.
Bryan House
It is that phase of my life! I'm just turning 30 in a month, working with Drupal for 7 years and just had my third Acquia anniversary a week ago. Time to look back and evaluate how things went, all the good and bad things; even better if the wisdom can be shared with others. This was part of my thinking when I submitted the session titled "Come for the software, stay for the community" for Drupalcon Copenhagen.
Gábor Hojtsy
It sounded like a really simple request: "Is it easy to add a search filter for 'My posts'?". In other words, add a search result facet for posts by the current (logged in) user through the Apache Solr Search Integration module APIs?
But then the wheels start turning - we want not just one blind link, but a real facet link that tells us how many results we'll get. Also, if we are filtering by 'My posts' then we probably have an equal use case for the opposite filter 'Posts not by me'. So we really need a facet block with two links and facets counts.
Peter Wolanin







Comments
This might be a good
This might be a good candidate for the expanded D7 install profile (or even part of the per user dashboard in some way). For bonus points, show unpublished status plus quick edit links.
Robert Douglass
Actually, the same client is
Actually, the same client is using the Publish Content module to add those publish/unpublish links. That was in fact, the essence of his use case. I just abbreviated the case study.
Robert Douglass
Senior Drupal Advisor, Acquia
Great idea. Much
Great idea. Much appreciated. Implemented on my site as soon as I saw it here.
Hello Robert, I have some
Hello Robert, I have some problems with step 4. I checked your PDF but I seem to cannot find the clue. Can you help me out?
Greetings,
Debra@ Anxiety Cures
Greetings! I tried to have
Greetings!
I tried to have the same results with comments made by the user. The problem is that it displays the comments made in *own* nodes and not *all* comments.
Any tip on what Fields/Filter can enable a view of a selection of all comments including both of those made on others' nodes as well as own nodes.
Robert Douglass
I think this recipe is
I think this recipe is deprecated by the Views Attach module which addresses the use case directly: http://drupal.org/project/views_attach
Robert Douglass
Senior Drupal Advisor, Acquia