Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hiding Sub-Forums


  • JimmyVT
    Participant

    @jimmyvt

    Greetings,

    After searching and reading around a bit, I still cannot resolve this “issue”. Basically I’d like to hide the sub-forums from my homepage So that only the category or parent forum shows up.

    I came across this post:

    http://bbpress.org/forums/topic/hide-subforums-on-main-page

    which seemed to offer a quick fix of replacing one line of code:

    <?php if ( bb_forums() ) : ?>

    to

    <?php if ( bb_forums("depth=1") ) : ?>

    Unfortunately this does not seem to work.

    If any further information is needed, please let me know! Thanks very much!

Viewing 8 replies - 1 through 8 (of 8 total)
  • <?php if ( bb_forums() ) : ?>
    <h2><?php _e('Forums'); ?></h2>
    <table id="forumlist">

    <tr>
    <th><?php _e('Main Theme'); ?></th>
    <th><?php _e('Topics'); ?></th>
    <th><?php _e('Posts'); ?></th>
    </tr>
    <?php while ( bb_forum() ) : ?>
    <?php if (bb_get_forum_is_category()) : ?>
    <tr<?php bb_forum_class('bb-category'); ?>>
    <td colspan="3"><?php bb_forum_pad( '<div class="nest">' ); ?><a>"><?php forum_name(); ?></a><?php forum_description( array( 'before' => '<small> – ', 'after' => '</small>' ) ); ?><?php bb_forum_pad( '</div>' ); ?></td>
    </tr>
    <?php continue; endif; ?>
    <tr<?php bb_forum_class(); ?>>
    <td><?php bb_forum_pad( '<div class="nest">' ); ?><a>"><?php forum_name(); ?></a><?php forum_description( array( 'before' => '<small> – ', 'after' => '</small>' ) ); ?><?php bb_forum_pad( '</div>' ); ?></td>
    <td class="num"><?php forum_topics(); ?></td>
    <td class="num"><?php forum_posts(); ?></td>
    </tr>
    <?php endwhile; ?>
    </table>
    <?php endif; // bb_forums() ?>


    JimmyVT
    Participant

    @jimmyvt

    Hrmm, that didn’t seem to do the trick for me. That code appears to have some stray “> as well.

    There are some other forum posts about this same thing. Maybe you’d have some luck checking out those?


    JimmyVT
    Participant

    @jimmyvt

    I already have, they’re very very old and so any links with code in them (via Postbin) is gone.

    I’d try cutting out this block of code in forum.php:

    <?php if ( bb_forums( $forum_id ) ) : ?>
    <h2><?php _e('Subforums'); ?></h2>
    <table id="forumlist">

    <tr>
    <th><?php _e('Main Theme'); ?></th>
    <th><?php _e('Topics'); ?></th>
    <th><?php _e('Posts'); ?></th>
    </tr>

    <?php while ( bb_forum() ) : ?>
    <tr<?php bb_forum_class(); ?>>
    <td><?php bb_forum_pad( '<div class="nest">' ); ?><a href="<?php forum_link(); ?>"><?php forum_name(); ?></a><small><?php forum_description(); ?></small><?php bb_forum_pad( '</div>' ); ?></td>
    <td class="num"><?php forum_topics(); ?></td>
    <td class="num"><?php forum_posts(); ?></td>
    </tr>
    <?php endwhile; ?>
    </table>
    <?php endif; ?>


    Olaf Lederer
    Member

    @finalwebsites

    This works for me…

    function bb_forum_depth( ) {

    global $bb_forums_loop;

    if ( !is_object($bb_forums_loop) || !is_a($bb_forums_loop, 'BB_Loop') )

    return false;

    return $bb_forums_loop->walker->depth;

    }

    <?php while ( bb_forum() ) : ?>

    <?php if (bb_get_forum_is_category()) : ?>

    <tr<?php bb_forum_class('bb-category'); ?>>

    <td colspan="3"><?php bb_forum_pad( '<div class="nest">' ); ?>"><?php forum_name(); ?><?php forum_description( array( 'before' => '<small> – ', 'after' => '</small>' ) ); ?><?php bb_forum_pad( '</div>' ); ?></td>

    </tr>

    <?php continue; endif; ?>

    <?php if (bb_forum_depth() <= 2 ) : ?> <!-- ******* -->

    <tr<?php bb_forum_class(); ?>>

    <td><?php bb_forum_pad( '<div class="nest">' ); ?>"><?php forum_name(); ?><?php forum_description( array( 'before' => '<small> – ', 'after' => '</small>' ) ); ?><?php bb_forum_pad( '</div>' ); ?></td>

    <td class="num"><?php forum_topics(); ?></td>

    <td class="num"><?php forum_posts(); ?></td>

    </tr>

    <?php endif; ?><!-- ******* -->

    <?php endwhile; ?>


    JimmyVT
    Participant

    @jimmyvt

    Hey hentdan! Thanks for your code snippet, that seemed to do the trick. I tweaked a couple things, namely <?php if (bb_forum_depth() <= 1 ) : ?>.

    Thank you very much!

    Here’s the complete code that’s working for me:

    <?php function bb_forum_depth( ) {
    global $bb_forums_loop;
    if ( !is_object($bb_forums_loop) || !is_a($bb_forums_loop, 'BB_Loop') )
    return false;

    return $bb_forums_loop->walker->depth;
    } ?>

    <?php while ( bb_forum() ) : ?>
    <?php if (bb_get_forum_is_category()) : ?>
    <tr<?php bb_forum_class('bb-category'); ?>>
    <td colspan="3"><?php bb_forum_pad( '<div class="nest">' ); ?><a href="<?php forum_link(); ?>"><?php forum_name(); ?></a><?php forum_description( array( 'before' => '<small> – ', 'after' => '</small>' ) ); ?><?php bb_forum_pad( '</div>' ); ?></td>
    </tr>
    <?php continue; endif; ?>
    <?php if (bb_forum_depth() <= 1 ) : ?> <!-- ******* -->
    <tr<?php bb_forum_class(); ?>>
    <td><?php bb_forum_pad( '<div class="nest">' ); ?><a href="<?php forum_link(); ?>"><?php forum_name(); ?></a><?php forum_description( array( 'before' => '<small> – ', 'after' => '</small>' ) ); ?><?php bb_forum_pad( '</div>' ); ?></td>
    <td class="num"><?php forum_topics(); ?></td>
    <td class="num"><?php forum_posts(); ?></td>
    </tr>
    <?php endif; ?><!-- ******* -->
    <?php endwhile; ?>

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

You must be logged in to reply to this topic.