Skip to:
Content
Pages
Categories
Search
Top
Bottom

custom recent activity column


  • deathbybear
    Participant

    @deathbybear

    hey everyone – i’m a newbie at wordpress, bbpress and php – but pretty decent with general html/css stuff.

    i’m working on customizing a bbpress installation with the twentyten bbpress theme and want to set it up so on the main “Forums” page there is a Recent Activity column that displays information about the most recent post –

    1. the topic the post was made in

    2. the poster

    3. the poster’s avatar

    4. how long ago the post was mad

    i have edited the loop-forums.php file to add the additional “Recent Activity” column to to the list of Forums – now I just need to figure out how to pull those pieces of information into the column.

    i have created a placeholder column in loops-single-forum.php file where the information will be pulled, i just don’t know how to get it in there – i imagine there are existing functions i can call to pull this data, i just don’t happen to know what those are or where to find them!

    any guidance you could give me would be greatly appreciated. thanks a lot!

Viewing 1 replies (of 1 total)

  • Lynq
    Participant

    @lynq

    Hi deathbybear,

    The only way I have found to make this happen is to edit the core code provided by bbpress.

    I am not sure if this is the right way to go, so if someone else can suggest another way then let me know.

    Here is what I have done. I replaced the bbp_list_forums function inside forum-template.php and then inside the loops-single-forum I changed the arguments to enable the last poster.

    function bbp_list_forums( $args = '' ) {

    // Define used variables
    $output = $sub_forums = $topic_count = $reply_count = $counts = '';
    $i = 0;
    $count = array();

    // Defaults and arguments
    $defaults = array (
    'before' => '<ul class="bbp-forums">',
    'after' => '</ul>',
    'link_before' => '<li class="bbp-forum">',
    'link_after' => '</li>',
    'count_before' => ' (',
    'count_after' => ')',
    'count_sep' => ', ',
    'separator' => ', ',
    'forum_id' => '',
    'show_topic_count' => true,
    'show_reply_count' => true,
    'freshness_before' => '<td class="last-posted-box">',
    'freshness_after' => '</td>',
    'show_freshness_link' => true,
    'freshness_author_before' => '<div class="author-box">',
    'freshness_author_after' => '</div>'
    );
    $r = wp_parse_args( $args, $defaults );
    extract( $r, EXTR_SKIP );

    // Bail if there are no subforums
    if ( !bbp_get_forum_subforum_count( $forum_id ) )
    return;

    // Loop through forums and create a list
    if ( $sub_forums = bbp_forum_get_subforums( $forum_id ) ) {

    // Total count (for separator)
    $total_subs = count( $sub_forums );
    foreach ( $sub_forums as $sub_forum ) {
    $i++; // Separator count

    // Get forum details
    $count = array();
    $show_sep = $total_subs > $i ? $separator : '';
    $permalink = bbp_get_forum_permalink( $sub_forum->ID );
    $title = bbp_get_forum_title( $sub_forum->ID );

    // Show topic count
    if ( !empty( $show_topic_count ) && !bbp_is_forum_category( $sub_forum->ID ) )
    $count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID );

    // Show reply count
    if ( !empty( $show_reply_count ) && !bbp_is_forum_category( $sub_forum->ID ) )
    $count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID );

    // Counts to show
    if ( !empty( $count ) )
    $counts = $count_before . implode( $count_sep, $count ) . $count_after;

    // Show topic count
    if ( !empty( $show_freshness_link ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
    $freshness_link = bbp_get_forum_freshness_link( $sub_forum->ID );
    $freshness_author = $freshness_author_before . bbp_get_author_link( array( 'post_id' => bbp_get_forum_last_active_id( $sub_forum->ID ), 'size' => 14 ) ) . $freshness_author_after;
    $freshness_link = $freshness_before . $freshness_link . $freshness_author . $freshness_after;
    }

    // Build this sub forums link
    $output .= $link_before . '<a href="' . $permalink . '" class="bbp-forum-link">' . $title . $counts . $freshness_link . '</a>' . $show_sep . $link_after;
    }

    // Output the list
    echo $before . $output . $after;
    }
    }

    Let me know how you get on, good luck!

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.