Info
- 2 posts
- 1 voice
- Started 3 months ago by Raziel_LOK
- Latest reply from Raziel_LOK
- This topic is resolved
Advice with forum tree customization
-
- Posted 3 months ago #
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_3Any help will be aprecieted. Thank you.
-
- Posted 3 months ago #
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]
-
You must log in to post.