0

I currently have a build in progress and am trying to achieve somthing that seems to be simple but is proving not quite so.

I would like to list say 50 entries, those 50 entries should be in a chronological order of either entry_date or last_comment_date. Using entry_date is fine for strict chronological but I'm also looking to see last_comment_date as well. If last_comment_date is newer then anothers entry_date then it should be higher up the tree.

Using orderyby="most_recent_comment|entry_date" yields most recent comments first then lists by entry date which isnt what is required.

I basically want to order by the last activity date - comment or entry. Is this approach possible ?

1 Answer 1

0

I ended up using Stash. Stash records each entry into a stash_list with an extra item that checks if there is at least one comment (if there is it must be newer then the entry_date) if there are no comments then the entry_date is the value.

Save the result of the if if:else as Unix Timestamp and then use stash:get_list and orderby the Unix Timestamp Var :)

{stash:activity_date}
{if comment_total > 0}{recent_comment_date format="U%"}{if:else}{entry_date format="%U"}{/if}
{/stash:activity_date}

Yet another reason to use Stash :)

1
  • 1
    It looks like a good solution, but the edit_date can be newer than the recent_comment_date. I suggest you to update your code.
    – Sobral
    Commented Aug 17, 2013 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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