1

Trying to find the easiest way to include the first most recent comment in my view that is using the 'teaser' mode. I am using the rate module to display number of votes in the view as well which doesn't have a 'field' to add so that is why I need to use teaser mode instead of fields mode. Thanks

  • ugh Found it, in the view under FORMAT click on the Teaser link and there is a checkbox to display comments. – Chris Jan 27 '12 at 19:22
4

Add Views, Token, and Viewfield modules.

Make a new view. The first page gives you most of it: Show comments, newest first. Make a page, limit the number to 1. Continue & Edit, and set the contextual filter to Content: Nid. Be sure and save it. :-)

Edit your content type. Add a new field, of type Views. Set the default view to be the 'recent comment' one you just made. Under 'Default Values,' have it always use the default view, and have [node:id] as an argument. Save that.

Now you can manage the display of this field in the 'manage display' tab, and place it in the 'teaser' view.

You might find that showing the whole comment under the teaser looks wrong, so then it's time to go back to the view and tweak it so it uses fields instead of the whole comment.

HTH.

  • I like this method have not used the Viewfield module before, it opens up a lot of possibility. I already did it by adding comments to teaser and hiding them in the node tpl then picking out just the most recent one using the text_summary() function to just display some of it. I will give this credit for a good answer because it doesn't involve coding like my solution did. – Chris Jan 27 '12 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.