views:

1193

answers:

3

I'm wondering how I can display the recently created nodes by a user on their profile page. I've created a new page for a user at /user/%user and I want to be able to display the latest nodes created by that user.

+1  A: 

Put in a Views Argument that uses the User ID from the URL argument. It will be arg(1). That should filter content that was authored by the profile you are looking at. That can work for a block or content pane.

Kevin
+10  A: 

ok, the answer involves creating a drupal view, so you will need the views module and although simple, the answer is lengthy. please bear with me through this... :) (i am actually doing this on a test site as i write the instructions, to make sure i dont miss anything...)

i assume that you know how to download and install the views module. make sure you also enable the views-ui module.

  1. go to site building->views->add.
  2. put "recent_posts_by_user" for view name, "recent posts by user" for description and "node" for view type. hit next.
  3. under the "default" view type, on the "fields" block, hit the "+" sign.
  4. under "groups" select node, then check the "node type", "node title" and "node updated date" fields. hit the "add" button below the list.
  5. under basic settings block (on the left), click on the "10" for "items for display" and change to "5" or however many items you want per page, and hit "update"
  6. under "use pager", click on "no" and "full pager" or "mini pager" and hit "update" again.
  7. under style, hit "unformatted" and change it to "table" set all fields to sortable, then choose the "updated date" as "default sort", then on "default sort order", select "descending". hit update.
  8. hit "save" to save your progress thus far.

default view is done. YAY! lets add the block

  1. now on the drop-down that says "page", select "block" and hit "add display".
  2. hit "arguments" (block title on the center of the screen)
  3. hit "override" and "update"
  4. hit the "+" sign to the right of "arguments"
  5. on the "groups" drop down, select "user" and select "user id". hit "add"
  6. under "Action to take if argument is not present", select the last option "provide default argument", select "user id from url" and check "Also look for a node and use the node author"
  7. under "validator", select "user" and "Allow both numeric UIDs and string usernames"
  8. under "Action to take if argument does not validate" select "hide view/page not found (404)"
  9. hit "update" then "save"

view is created now lets make sure it shows up on the right pages.

  1. go to site building->blocks, search for the "recent posts by user" block and hit "configure"
  2. scroll all the way to the bottom and select "Show on only the listed pages." and put in "users/*" under the "pages" text area
  3. hit "save block"
  4. now find the "recent posts by user" block again and set it to "content bottom" region (or any other region your theme has available).
  5. hit "save blocks"

DONE! Not rocket-science, but lengthy process... drupal 6 views is so much better than drupal 5! :)

now go visit a user page http://site/users/username and see the table show up there!

hit me up if you still have questions about views.

enjoy

Peter Carrero
Thanks a million Peter, that works perfectly!
Mongey
You are welcome! I'm glad this worked for you.
Peter Carrero
A: 

Well. I jus prefer you to go to Views -> Sort Criteria and add the Node:Updated Date and mark it as desending as it shows the granularity over the time. Moreover, you can also get the recent node not only to the table style but to all.

Cheers...

Bala

related questions