Skip to:
Content
Pages
Categories
Search
Top
Bottom

Freshness of the forums list as a normal date


  • baylock
    Participant

    @baylock

    Hello,

    I read a lot of questions around here related to the change of the freshness to a simple date.
    But each one of the answers are related to a forum posts lists.
    What I want is to display the last post date in the freshness column of the forums lists.

    How would i do that?

    I believes this has something to do with this line:
    $time_since = bbp_get_forum_last_active_time( $forum_id );

    Or maybe this one:
    apply_filters( 'bbp_get_post_time', $anchor, $forum_id, $time_since, $link_url, $title, $active_id );

    But how to get the normal date from that (d-m-Y), it’s a mystery to me.

    Thank you for your help.

    BBPress: 2.4
    WP: 3.7

Viewing 3 replies - 1 through 3 (of 3 total)

  • baylock
    Participant

    @baylock

    Please guys, this is not something trivial.

    I tried to work it out but I couldn’t as there is not a single post around here answering that and there is nowhere I can find a comprehensive list and description of the BBPress functions.

    All BBpress functions I happened to find that are related to the dates are displaying them in a sophisticated way, there is none I could find that just displays the date in its simplest form.
    I tried to “date()” and “strtotime()” every single variable I could find but with no success.

    There are posts telling how to use flat dates around here but these posts are very old (4 years..) and they make use of functions that don’t exist anymore.
    There was supposed to be a plugin for that but this plugin doesn’t exist anymore neither.
    And the more recent questions about this issue are just not answered.

    I hope this will not be taken the wrong way: I’m very grateful for this plugin and for all the people working on it. Really. I just don’t know how to move on with an unanswered question and some outdated answers.

    PS: I asked you how to get the latest post date in the forum list view but now, I also (and mainly) need to know how to achieve this in the topic list view and posts view as they are not documented neither.
    Long story short: how to get real dates everywhere!

    It’s been two days and I’m still in the dark. If it’s there somewhere, my bad, but please be assured that, as obvious as it might be, I tried my best.

    Thank you very much for your help.


    koendb
    Participant

    @koendb

    This should get you started: bbp_get_reply_post_date on sourcexref

    I feel the same way. It’s great how much work is being put into this plugin, but the support isn’t great. And finding out what information is still valid for the current bbpress version is sometimes difficult.

    But in general: you could google every function and after a few days you’re used to and can guess the very logical named function names.

    Good luck. (and keep me updated)


    baylock
    Participant

    @baylock

    Ok, thank you!

    I achieved what I wanted, this way:

    Forums list:

    <p class="bbpx-topic-meta">
        <?php
        $forum_id  = bbp_get_forum_id();
        $last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true );
        if ( empty( $last_active ) ) {
            $reply_id = bbp_get_forum_last_reply_id( $forum_id );
    	if (!empty( $reply_id)){$last_active = get_post_field( 'post_date', $reply_id );} 
            else 
            {
    	    $topic_id = bbp_get_forum_last_topic_id( $forum_id );
                if (!empty( $topic_id)){$last_active = bbp_get_topic_last_active_time( $topic_id );};
    	};
        };
        $date= date('d/m/Y',bbp_convert_date( $last_active ));
        $active_id = bbp_get_forum_last_active_id( $forum_id );
        $link_url  = $title = '';
    
        //these two next lines are beyond me: same condition, two results for the same variable...
        if (empty($active_id)){$active_id = bbp_get_forum_last_reply_id( $forum_id );};	
        if (empty($active_id)){$active_id = bbp_get_forum_last_topic_id( $forum_id );};
    
        if (bbp_is_topic($active_id)) 
        {
    	$link_url = bbp_get_forum_last_topic_permalink( $forum_id );
    	$title    = bbp_get_forum_last_topic_title( $forum_id );
        } 
        elseif (bbp_is_reply($active_id)) 
        {
    	$link_url = bbp_get_forum_last_reply_url( $forum_id );
    	$title    = bbp_get_forum_last_reply_title( $forum_id );
        };
        $time_since = bbp_get_forum_last_active_time( $forum_id );
        if (!empty($time_since) && !empty($link_url) 
        {
    	$anchor = '<a href="'.esc_url($link_url).'" title="'.esc_attr($title).'">'.$date.'</a>';		
            ?>
            <span class="bbp-topic-freshness-author">
              <?php
                  bbp_author_link(array('post_id'=>bbp_get_forum_last_active_id(),'size'=> 14));
              ?>
            </span>
            <?php	
        }
        else {$anchor = 'esc_html__( 'No Topics', 'bbpress' );};
        ?>
    </p>
    		
    <?php
    echo apply_filters( 'bbp_get_post_time', $anchor, $forum_id, $time_since, $link_url, $title, $active_id );
    ?>

    Topics list:

    <p class="bbp-topic-meta">
        <span class="bbp-topic-freshness-author"><?php bbp_author_link(array('post_id =>bbp_get_topic_last_active_id(),'size'=>14)); ?></span>
            <?php
    	$topic_id   = bbp_get_topic_id();
    	$reply_id   = bbp_get_topic_last_reply_id();
    	$title      = bbp_get_topic_last_reply_title( $topic_id );
    	$link_url   = bbp_get_topic_last_reply_url( $topic_id );
    	$date   = get_post_time( 'd/m/Y', $gmt, $reply_id, true );
    	$anchor = '<a href="'.esc_url($link_url).'" title="'.esc_attr($title).'">'.esc_html($date).'</a>';
    	echo apply_filters( 'bbp_get_topic_freshness_link', $anchor, $reply_id, $result, $link_url, $title );	
    	?>
    </p>

    As you can see, I didn’t hook anything already. So far I just got rid of the “bbp_topic_freshness_link()” in the templates and simply replaced the initial function by these lines, just to make a test. I still have to make a function out of these.

    Not happy with this mess as I’m sure it’s more complicated that it should be, but it works.

    Thank you for your guidance koendb!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar