Hello, i need to show users post on their profiles from only one content type.

Is there any options to do this?

Also i would like if there are possibilities to style it, show fields from post..

Please help me!

Thank you very much!

Comments

webbykat’s picture

Priority: Normal » Major
Status: Closed (works as designed) » Active

A view argument will allow you to do this. Here are the steps:

  • Take a look at a typical user page on your site. If it has a number in the URL, you probably need the user ID. If it has a name in the URL, you need the username. For example, on my site, my user page is /users/webbykat, so I know my username is the relevant bit of data here. If memory serves, D6 sites frequently use the ID and D7 sites frequently use the username.
  • Create a new content view with a block display. Set it to display titles, teaser, whatever you want. This is where you can also choose the content type you want to display.
  • If there's a number in the user page URL, add a contextual filter for "Content: Author uid."
  • If there's a username in the user page URL, first add the "Content: Author" relationship, then add a contextual filter for "User: Name." If you don't add the relationship first, you won't see the User: Name contextual filter as an option.
  • Pick "Provide a default argument" (Drupal 6) or "Provide default value" (Drupal 7) with the type "User ID from URL." If you skip this post, all posts by all users will appear on each user page (not just that user's posts).
  • Save the view. Assuming you added the block display correctly, the block is now available on the Structure > Blocks page. Go there and open your block.
  • Set your block to display on /users/* (or whatever matches your user URL - the * is a wildcard, so it will appear on both /users/webbykat and /users/webstar) in the correct region.
  • Save the block.

You should now be able to see a list on your user pages, and can edit it to get it looking the way you want.

webbykat’s picture

Priority: Major » Normal
webbykat’s picture

Status: Active » Closed (works as designed)
johnhorning’s picture

Priority: Major » Normal
Status: Active » Closed (works as designed)

For Drupal 7, I had to do a little more than is described in #2 above. For the "User: UID" contextual filter, under "When the filter value is NOT available", I checked "Provide default value", then selected "User ID from URL", as described above.

Then under "When the filter value IS available or a default is provided", I checked "Specify validation criteria", then selected "User" under "Validator", and selected "Allow both numeric UIDs and string usernames".

Seems to work, although wish I could explain exactly why.