Happy New Year to everyone!

I have implemented a solution described in this node - http://drupal.org/node/235161. It's adding a list od recent comments in the profile page. I would like to display all the comments from a specific user, but with a pager, so that the profile page displays 10 comments. If you want to see other comments, you would need to use the pager. How to modify the code to do this?

Thank you in advance!

Comments

Jeff Burnz’s picture

I would do this with Views - use the UID as the argument and create list of comments with pager, you can embed that view in the user profile tpl.

lion123’s picture

Thank you for your reply. I have used the video on gotdrupal.com, but arguments are very complicated, and the result is not what I want. I would like to have a list of comments of every user on his/her profile page. By using arguments, user can see only his comments.

Also, I have a problem when using views to filter comments. It shows me the list of all the comments on that forum topic. For example, I opened a topic "Drupal is best", and it shows me all the comments on that topic as I'm the author. And I'm not :)

So, that snippet I mentioned in my first post is really great and simple, except that problem with the pager. Is there a way to create it? Thank you in advance.

Anonymous’s picture

Views is really the solutions to this, you don't have to code. In your profile, set the argument to be the user whos profile is being viewed. Lets say your viewing my profile, the url would be users/inocram. Then In you views you can set the argument to custom args using arg(1) which points to the username.

In the forum, I suspect your views is being filtered by currently logged-in user. If the author's username cannot be fetched from the url, load the views programmatically using views_embed_view then pass in the author's name or uid as argument.

You can read more about views_embed_view here: http://thedrupalblog.com/embedding-view-drupal-6-using-views-embed-view

lion123’s picture

Views would be a good solution, but, as I mentioned before, it returns me unwanted results.

It shows the list of all the comments on that forum topic. For example, I open a topic "Drupal is best", and it shows me ALL the comments on that topic in MY recent comments list, like I'm the author. And I'm not :)

Can you please tell me how to configure that view? This is my setup:

fields - comment body, comment title
argument - user id
filter - user - currently logged in, vocabulary - forum

Anything I'm missing?

Jeff Burnz’s picture

Yeah... I think you are missing the gist of args and filters.

argument - user id : args are things in the URL, like the users ID, so this only works on user pages - such as their profile page or a View where the UID is actually in the URL. Beware, blocks dont take args, so you have to use the default view or a page view and embed it in the template OR use Panels + ctools to pass context back to the View.

My guess is that you have set "Display all values" for the arg when the arg is missing, thus your view is acting correctly and giving you the whole list.

Views is very powerful and takes some time to come to grips with, and one thing is true, Views NEVER returns what you don't ask for...

lion123’s picture

No, I have set it to "Hide view / Page not found (404)". I must be missing something else, but don't know what.

kaakuu is right, views export would be the best and fastest thing ,that way we could see where's the problem.

kaakuu’s picture

This will be really a good one, can some one please post an exact Views export as a page? Then it can be added as page/block/whatever. Cheers for the solution.