I just started using profile2 module to implement 2 types of profile for my site visitors (sellers, buyers for example). Both type of users can post content (say articles). I know whenever someone posts an article, a relationship is created in the db between that user and article. What I want to do is to show a user's articles under that user's profile page (the page that the profile2 module creates). With drupal 6 and content profile, this was easily done with a few modules since profiles were nodes back then. I'm guessing I'll have to code up a module to do this since profile2 profiles aren't nodes anymore. Can you guys give me some pointers on how you'd/you've gone about accomplishing this? Much thanks!
1 Answer
Views is the way to go. Create a view with a block that lists articles, add a contextual filter to the user id and configure it to provide a default argument from the url. Then add that block to the user profile page, you should be set.
- thanks dude. I've done this using contextual views as you explained. However, I'm using the profile2 module. This module allows you to extend a user profile with fields. Those additional fields can be displayed in another page. When you're on that new page, you don't have access to the original userid (only the profile id). I didn't see the profile id being exposed when I was doing the contextual filter, but if I use the userid, then this has no effect. e.g. profile id = 2, userid = 3. The views block shows when on user/3 but not profile/2berto77– berto772011-12-22 17:56:55 +00:00Commented Dec 22, 2011 at 17:56
- I guess this problem can be solved by using relationships instead of contextual filters. Another possible solution would be to use php to provide the default argument instead of getting it from the url.ipwa– ipwa2011-12-22 21:31:25 +00:00Commented Dec 22, 2011 at 21:31