Skip to:
Content
Pages
Categories
Search
Top
Bottom

My customized sub-sub-forums


  • tazogamer
    Participant

    @tazogamer

    I HAVE DONE THAT, but you need to read all these instruction and do a customization:

    
    
    //using add_filter, i have changed one original bbPress function (named bbp_list_forums, created from bbpress\includes\forums\template.php function)
    // copied  that function, and inserted the additional code (you can easily see my added extra code)
    //so, after some time, someone, who will work on this website, may have to update the below "bbp_list_forums" function (according from the new version of bbPress package,as now its 2013-14 year), and insert again my added code in its place..
    
    add_filter('bbp_list_forums','bbp_list_forumsNEWWWW',10);
    function bbp_list_forumsNEWWWW( $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'      => ' (',
    		'count_after'       => ')',
    		'count_sep'         => ', ',
    		'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 );
    
    			// 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
    			if ( !empty( $r['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 = $r['count_before'] . implode( $r['count_sep'], $count ) . $r['count_after'];
    			}
    
    			
    			
    			
    			
    			
    			
    			
    				//------------------------------------------------------------------------------------------------	
    		//------------------------------------------------------------------------------------------------
    		// ------------------------------------------------ HERE WHAT I HAVE ADDED ------------------------
    		//------------------------------------------------------- START -------------------------------
    		//------------------------------------------------------------------------------------------------
    		$fresnhesss=bbp_get_forum_last_topic_title( $sub_forum->ID );
    		if(empty($fresnhesss))	{$fresnhesss='NO TOPICS';}
    		else {$fresnhesss='<a href="'. bbp_get_forum_last_topic_permalink( $sub_forum->ID ) .'">'. $fresnhesss .'</a>';}
    		
    			// Build this sub forums link
    			$output .= $r['link_before'] . '
    				<li class="forumsSUUB">
    					<div class="s_LINe"><a  href="' . esc_url( $permalink ) . '" class="bbp-forum-link">__' . $title . $counts . '</a></div>' .
    					$show_sep . '
    					<div class="bbp-forum-lastactivee">'.$fresnhesss.'</div> 
    					<div class="bbp-forum-contenttt-descr">'. bbp_get_forum_content($sub_forum->ID) .'</div> 
    				</li>' . $r['link_after'];
    			
    
    		// sub-sub-forums list
    		$sub_forums2 = bbp_forum_get_subforums( $sub_forum->ID );
    		if ( !empty( $sub_forums2 ) ) {
    		
    		$i = 0;
    			// Total count (for separator)
    			$total_subs = count( $sub_forums2 );
    			foreach ( $sub_forums2 as $sub_forum2) {
    			
    				$i++; // Separator count
    
    				// Get forum details
    				$count     = array();
    				$show_sep  = $total_subs > $i ? $r['separator'] : '';
    				$permalink = bbp_get_forum_permalink( $sub_forum2->ID );
    				$title     = bbp_get_forum_title( $sub_forum2->ID );
    
    				// Show topic count
    				if ( !empty( $r['show_topic_count'] ) && !bbp_is_forum_category( $sub_forum2->ID ) ) {
    					$count['topic'] = bbp_get_forum_topic_count( $sub_forum2->ID );
    				}
    
    				// Show reply count
    				if ( !empty( $r['show_reply_count'] ) && !bbp_is_forum_category( $sub_forum2->ID ) ) {
    					$count['reply'] = bbp_get_forum_reply_count( $sub_forum2->ID );
    				}
    
    				// Counts to show
    				if ( !empty( $count ) ) {
    					$counts = $r['count_before'] . implode( $r['count_sep'], $count ) . $r['count_after'];
    				}
    
    			//fresnhess		
    			$fresnhesss2=bbp_get_forum_last_topic_title( $sub_forum2->ID );
    			if(empty($fresnhesss2))	{$fresnhesss2='NO TOPICS';}
    			else {$fresnhesss2='<a href="'. bbp_get_forum_last_topic_permalink( $sub_forum2->ID ) .'">'. $fresnhesss2 .'</a>';}
    			
    				// Build this sub forums link
    				$output .= '
    				<li class="bbp-forum forumsSUUB">
    					<div class="subsub_LINe"><a  href="' . esc_url( $permalink ) . '" class="bbp-forum-link">__' . $title . $counts . '</a></div>' .
    					$show_sep . '
    					<div class="bbp-forum-lastactivee">'.$fresnhesss2.'</div> 
    					<div class="bbp-forum-contenttt-descr">'. bbp_get_forum_content($sub_forum2->ID) .'</div> 
    				</li>';
    			}
    		}
    		//------------------------------------------------------------------------------------------------
    		//------------------------------------------------------------------------------------------		
    		//----------------------------- END of my inserted code (then continues normally)-----------
    		//------------------------------------------------------------------------------------------	
    		////------------------------------------------------------------------------------------------------	
    			
    			
    			
    			
    			
    			
    		
    			
    		}
    
    		// Output the list
    		echo apply_filters( 'bbp_list_forumss', $r['before'] . $output . $r['after'], $r );
    	}
    }	
Viewing 3 replies - 1 through 3 (of 3 total)
  • Nice and thanks for sharing your code. 🙂

    (I moved this to it’s own topic rather than at the bottom of an old topic)


    nicmare
    Participant

    @nicmare

    awesome “hack”. thank you! i need this.


    wplove3268
    Participant

    @wplove3268

    This looks like exactly the solution I need to display sub-sub forums on my forum index page. Unfortunately I tried it and got a blank screen. Does anyone know if this patch is still valid for the most recent version of bbPress?
    Also-it looks like the file to be edited is outside the “Templates” folder:
    plugins/bbpress/includes/forums/template.php
    Is it possible to modify the templates.php file and put it in my child theme to protect it from future updates?
    This guide only refers to files in the template folder.

    Thanks.

    Edit: scratch the first question-I got it to work I had just pasted the code incorrectly. Still need to know if it’s possible to put this modified file into a theme folder.

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