Hi,

I'm using the jobtrack (now known as the support module) and views to generate a list of recent active jobs that have being posted. To accept a job someone adds a comment as per the normal workflow of the module. To close that job once its complete the user adds another comment again this is the correct operation of the module.

My problem is with the view I have generated to display these jobs. At present everytime a comment is added the table of my view adds another duplicate line of the node for each individual comment. So if there are, for example, 3 comments per node I have 3 pretty much identical lines on my views table the only difference being the commented dates/times.

Is there any way I can filter my view to just display the most recent commented date/time and not generate a duplicate for each comment?

I hope that all makes some sort of sense I'm sure its easily done I just can seem to get it to work.

Thanks,
Paddy

Comments

yakker’s picture

I have a list of nodes pulled in Views by way of a couple of filters. Below each node listing, I want to display a single comment - the most recent. In Views, by selecting Fields, I have the option of displaying the most recent comment-ER, the date it was posted, but not the comment itself. If I select comment Body, I get ALL comments. Is there any way to just have the most recent comment body displayed in a node view?

I tried creating a comment view separately which took a node id as an argument. I then built a tpl.php template to correspond to my original node view (the one in which I wanted to be able to select recent comment body, but couldn't), and included a call to views_embed_view() right beside print $row inside the template file. But I can't find a way to dynamically pass the node id to that function so that it corresponds exactly to the nodes being selected by the original node view.

Right now, I think my only option is to include logic in template.php that spits out exactly the same nids as the original view obtains by way of its filter, and then to implement views_embed_view() inside a loop which will cycle through that array of nids as arguments to pass.

Any better solutions would be very welcome!
Chris

shnafoo’s picture

I have a table with projects, and I want to display the most recent comment for each of them. When I use the "Fields - Comment: Body" it shows all the comments, with the almost identical lines. I just want the most recent one.

thank you for your help!

pvanerk’s picture

Any idea on this? Got the same problem.

pvanerk’s picture

Have a look at this: http://drupal.org/node/292126#comment-4296178

Use the rule module to populate a CCK-field with the latest comment. I have used this populate fields for author / date / comment. I use it for author and date, because when there is no comment the default fields (last author etc.) picks the node author. This is not what I wanted, when there is no comment the field author should be empty.

Give users view access to the CCK fields, but hide them in your contenttype '?q=admin/content/node-type//display'. Now you can use the CCK fields in your view, but they won't show up when you view your node.