Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum bloc with subforum list


  • lucju04
    Participant

    @lucju04

    Hi everybody,

    I would like to creat a home for my forum who loop some forum in blocs. And in this bloc I would like to list sub forum with topic count, post count and freshness.

    I make a mockup to be more precise ^^ You can the here: https://ibb.co/zFD60d1

    I already try to make these loop but I can’t retrieve the freshness & counts for each sub forum.

    And also I need to design differently each row but bbpress retrieve data in columns…

    Do you already make something like this ?

    I found this function:

    //This function adds descriptions to the sub forums
    function custom_list_forums( $args = '' ) {
    
    	// Define used variables
    	$output = $sub_forums = $topic_count = $reply_count = $counts = '';
    	$i = 0;
    	$count = array();
    
    	// Parse arguments against default values
    	$r = bbp_parse_args( $args, array(
    		'before'            => '<ul class="bbp-forums-list">',
    		'after'             => '</ul>',
    		'link_before'       => '<li class="bbp-forum">',
    		'link_after'        => '</li>',
    		'count_before'      => ' <span class="counts">[ ',
    		'count_after'       => '  rΓ©ponse(s) ]</span>',
    		'count_sep'         => ' sujet(s), ',
    		'separator'         => ', ',
    		'forum_id'          => '',
    		'show_topic_count'  => true,
    		'show_reply_count'  => true,
    	), 'list_forums' );
    
    	// Loop through forums and create a list
    	$sub_forums = bbp_forum_get_subforums( $r['forum_id'] );
    	if ( !empty( $sub_forums ) ) {
    
    		// 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 ? $r['separator'] : '';
    			$permalink = bbp_get_forum_permalink( $sub_forum->ID );
    			$title     = bbp_get_forum_title( $sub_forum->ID );
    			$content = bbp_get_forum_content($sub_forum->ID) ;
    
    			// Show topic count
    			if ( !empty( $r['show_topic_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
    				$count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID );
    			}
    
    			// Show reply count
    				$count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID );
    
    			// Counts to show
    			if ( !empty( $count ) ) {
    				$counts = $r['count_before'] . implode( $r['count_sep'], $count ) . $r['count_after'];
    			}
    
    			// Build this sub forums link
    			$output .= $r['before'].$r['link_before'] . '<a href="' . esc_url( $permalink ) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'].'<div class="bbp-forum-content">'.$content.'</div>'.$r['after'];
    		}
    
    		// Output the list
    		return $output ;
    	}
    }
    
    add_filter('bbp_list_forums', 'custom_list_forums' );

    I got the description of subforum, it’s a good start..

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

  • Robin W
    Moderator

    @robin-w

    ok, two things

    1. you could just use the template in my

    bbp style pack

    once activated go to

    dashboard>settings>bbp style pack>forum templates

    2. if you want to alter that,
    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    then download my plugin and find template/templates1/loop-forums

    copy that file to your theme and put it in the bbpress directory


    lucju04
    Participant

    @lucju04

    Oh sorry I didn’t receive a mail alert for your answer πŸ˜‰

    I will check your plugin which look very uselful !! Thanks a lot πŸ˜‰


    lucju04
    Participant

    @lucju04

    Oh sorry I didn’t receive a mail alert for your answer πŸ˜‰

    I will check your plugin which look very uselful !! Thanks a lot πŸ˜‰

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