I want to create a view that shows the latest posts in a forum and also any latest comments. The comments and the posts would all show in the same view. Is it possible for me to do this?
Thanks in advance,
Ben
I want to create a view that shows the latest posts in a forum and also any latest comments. The comments and the posts would all show in the same view. Is it possible for me to do this?
Thanks in advance,
Ben
With Drupal 7 you can add a relationship Last comment and then add that field to the view.
In essence: no. Views requires you to choose one main resource in the first step: you there (amongst others) choose to go with either nodes, or comments.
However, with some (ugly) configuration, you can load the comments that go with nodes. Each result would look like, Node - Comment, e.g.:
and so on. With some styling, you can then get it to show comments and nodes in separate rows.
However, this is ugly and hackish. My advise: write a simple module that either exposes a block, or a menu+page, and do two simple (and light) queries on the database: SELECT nid, title, ... FROM {nodes} LIMIT 10
and SELECT nid, name AS title, ... FROM {comments} LIMIT 10
then mix these two up. Or, with some (more complex) SQL magic, you could even join the two tables and create fancy results that e.g. order by created date of either nodes or comments.
One idea I've seen is to use Views Custom Field to "attach" a wholly separate view with PHP code. See comment #4 for the code (in a request for this feature in Views. for a code example).