Forums

Join
bbPress Support ForumsThemesAdvice with forum tree customization

Info

Tags

Advice with forum tree customization

  1. After finding a lot I have not found a solution for showing more than 1 depth sub forums. So I made some coding.

    I changed "<?php bbp_list_forums(); ?>" on file loop-single-forum.php to:

    <?php

    $before = '<ul class="bbp-forums">';
    $after = '';
    $link_before = '<li class="bbp-forum">';
    $link_after = '';

    if ($sublist = bbp_forum_get_subforums($forum_id)) {
    echo $before;
    foreach ( $sublist as $sub_forum ) {
    // Get forum details
    $permalink = bbp_get_forum_permalink( $sub_forum->ID );
    $title = bbp_get_forum_title( $sub_forum->ID );

    echo $link_before . '' . $title . '' . $link_after;

    if ($sublist2 = bbp_forum_get_subforums($sub_forum->ID)) {
    echo $before;
    foreach ( $sublist2 as $sub_forum ) {
    // Get forum details
    $permalink2 = bbp_get_forum_permalink( $sub_forum->ID );
    $title2 = bbp_get_forum_title( $sub_forum->ID );

    // Build this sub forums link
    echo $link_before . '' . $title2 . '' . $link_after;

    }

    }

    echo $after;

    }
    }

    echo $after;

    ?>

    So my question is, Is there any way to do that little easier ? Or someone who is looking in the same issue and want give a hand to clean up this code.

    A example of the struture I'm looking:

    TEST
    -TEST_CHILD_1
    -TEST_CHILD_2
    --TEST_CHILD_CH1
    --TEST_CHILD_CH2
    -TEST_CHILD_3

    Any help will be aprecieted. Thank you.

  2. I made it, using the same code above, you can add your own class if you want. And including more loops you can list depeer forums.

    Here is the code:

    [code]

    <?php

    $before = '<ul class="bbp-forums">';
    $after = '';
    $link_before = '<li class="bbp-forum">';
    $link_after = '';

    if ($sublist = bbp_forum_get_subforums($forum_id)) {
    echo $before;
    foreach ( $sublist as $sub_forum ) {
    // Get forum details
    $permalink = bbp_get_forum_permalink( $sub_forum->ID );
    $title = bbp_get_forum_title( $sub_forum->ID );

    echo $link_before . '' . $title . '' . $link_after;

    if ($sublist2 = bbp_forum_get_subforums($sub_forum->ID)) {
    echo $before;
    foreach ( $sublist2 as $sub_forum ) {
    // Get forum details
    $permalink2 = bbp_get_forum_permalink( $sub_forum->ID );
    $title2 = bbp_get_forum_title( $sub_forum->ID );

    // Build this sub forums link
    echo $link_before . '' . $title2 . '' . $link_after;

    }

    echo $after;

    }

    }
    }

    echo $after;

    ?>

    [/code]

  3. You must log in to post.