insert space / break in thread after long duration

island

Well-known member
Licensed customer
It would be nice to have an option to insert a spacer between posts in a thread when a long time of x-days has passed between the new post and the last post.

So if a thread goes (30, 180, 365 depending on the subject) days between replies, a spacer is inserted "a year has passed between posts..." so it's clear that a time-gap occurred. That helps when you do want to update an older thread with new info, but keep it clear so users don't accidentally think the post up a few is newer than it is (where they often reply to something older after an update is made.)
 
Upvote 3
It's a feature I'd quite like. We do something like that already and it would be nice to have it "built in".

I've personally no issue with a thread being brought back if worthwhile discussion is added, but I've worked on boards where you get some newbie posting "I agree" or something to a ten year old thread, then someone posts "necropost", then someone else posts something and you get twenty off inane posts rather than anything constructive. Some boards of course close older threads to avoid this.

So for the sake of documentation and what can currently be done...

In the past we used to have just a widget at the end of a thread that was shown depending on the date of the last post. So the widget would say something like "this thread has been dead for more than two years ...". We used a display condition like so for the widget:
Code:
(($xf.time - $context.thread.last_post_date) > (86400 * 365 * 2)) && $context.thread.discussion_open && $xf.visitor.user_id
That works okay, but of course as soon as someone does post then the thread is "fresh" again and a lot of users might miss that it's an old thread.

So these days we actually have some template hacks (in thread_view) so that we've a couple of messages between posts which is more what you're suggesting. - At some point I should really look at doing it as an add-on instead of a direct template edit. -
There will be cleaner and better ways of doing this. I expect for instance you could probably skip 99% of the thread and just start checking when you hit the last few posts or maybe the last page, so caveat emptor as they say. I'm no XenForo template language expert so this is what I cobbled together some years back. Still I think what you are after can currently be done with a bit of hacking around. So simplified a little from what we actually use:

So we start by getting the date of the first post outside of the post loop so we have something to compare the dates on each of our posts to:
Code:
<xf:set var="$_post_keys" value="{{ array_keys($posts) }}" />
<xf:set var="$_last" value="{$posts.{$_post_keys.0}.post_date}" />
Then within the <xf:foreach loop="$posts" value="$post"> loop we compare the date of the current post with that of previous stored in $_last. If that's more than five years (in this example) we do a rough sum and display a message that will appear between the posts.
Code:
<xf:set var="$_gap" value="{{ $post.post_date - $_last }}" />
<xf:if is="{{ $_gap >= (5*365*86400) }}">
    <xf:set var="$_gap_years" value="{{ floor($_gap / (365*86400)) }}" />
    <xf:set var="$_gap_leftover" value="{{ ($_gap - ($_gap_years*365*86400)) }}" />
    <xf:set var="$_gap_leftover_vulgar" value="" />
    <xf:if is="{{ $_gap_leftover > (273*86400) }}"><xf:set var="$_gap_leftover_vulgar" value="¾" /></xf:if>
    <xf:if is="{{ $_gap_leftover > (243*86400) }}"><xf:set var="$_gap_leftover_vulgar" value="⅔" /></xf:if>
    <xf:if is="{{ $_gap_leftover > (182*86400) }}"><xf:set var="$_gap_leftover_vulgar" value="½" /></xf:if>
    <xf:if is="{{ $_gap_leftover > (121*86400) }}"><xf:set var="$_gap_leftover_vulgar" value="⅓" /></xf:if>
    <xf:if is="{{ $_gap_leftover > ( 91*86400) }}"><xf:set var="$_gap_leftover_vulgar" value="¼" /></xf:if>    
    <p>Your message explaining there was a  gap of {{ $_gap_years }}{{ $_gap_leftover_vulgar }} years between the posts above and below ...</p>
<xf:else/>
    <xf:set var="$_gap_years" value="" />
</xf:if>
We then chuck in another message the other side of the post so that above it we have one "showing" the gap and below it we have one telling those user unable to check dates that the post they are about to reply to is in itself a reply to an old thread. We then update the $_last variable for the next iteration of <xf:foreach loop="$posts" value="$post">
Code:
<xf:if is="$_gap_years">
<p>Your message saying that there had been a gap of {{ $_gap_years }}{{ $_gap_leftover_vulgar }} years in the thread BEFORE the last post</p>
</xf:if>
<xf:set var="$_last" value="{{ $post.post_date }}" />
I opted to do some vulgar fractions so that it was a bit looser in the message, but you could customise that however you wanted. You could obviously also optimise some of the calculations. I opted to do it based of 86400 (seconds), ie a day, so I'd easily remember what each bit was doing! I mean it's still magic numbers in code which makes me internally wince!
 
Back
Top Bottom