Hello.

I am using Views version 6.x-2.2 and I am overriding the tracker view "recent posts". My view consists of a mix of posts and comments. When these are sorted by last post (the last comment in the node) I get inconvinient results. All comments in a node are then pushed to the top, when a new comment is posted in that node.

When the view is sorted by the comment post date, the nodes without comments are pushed to the bottom.

The solution for this would be to make a new sortable date field. It should get the date from the comment or the node, if the node does not have any comments.

Pseudo:
sortDate = comment post date
if sortDate = 0 then
sortDate = node post date

Is there an existing solution for this?

Thanks.

Comments

grn’s picture

Is this place a bad spot to post this? Should I move this to the forums?

merlinofchaos’s picture

Status: Active » Closed (won't fix)

Views can't do this. You would have to write a custom sort handler. But remember, you need to use SQL to sort, not PHP, and it's kind of difficult to write the SQL like you have.

(Mixing comments + nodes in a list is always very tough, and Views isn't really built for that).

grn’s picture

Thanks for the comment. Now I know which way to go.

I appreciate it, thank you!