Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hiding Subforums’ Subforums from Subforum Pages


  • 755628
    Inactive

    Hi.

    This is an extension of this question: http://bbpress.org/forums/topic/hiding-subforums-on-the-homepage#post-11761

    My forum has forums, subforums, and then subforums of those subforums. Basically, there are three levels of forums.

    I was able to hide the subforums from the main forums page. But how do i hide the subforums’ subforums from the subforums pages, so that the visitor must click on the subforum to view the subforums’ subforums.

    I would really appreciate any help on this matter. I am not good at coding so it would be wonderful to get assistance! :)

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

  • _ck_
    Participant

    @_ck_

    The way I hide sub-forums on the front-page is to wrap the code that lists the forums in this simple code:

    <?php if (!$forum->forum_parent) { ?> <– this

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

    blah blah

    </tr>

    <?php } ?> <– and this

    It essentially just checks if the forum has a parent and doesn’t show it. Now on the forum page that’s a problem because any forum listed would have a parent. Gotta think about that one for a minute…

    Oh wait, I know what to do, we just have to check if the forum_parent is equal to the current forum id. This is untested but in theory should work:

    <?php $forum_parent=$forum_id; ?>
    <?php while ( bb_forum() ) : ?>
    <?php if ($GLOBALS['forum']->forum_parent==$forum_parent) { ?>
    <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 } ?>
    <?php endwhile; ?>


    755628
    Inactive

    Thank you for the response. I have very, very limited coding experience. Can you explain further please? Thank you.


    _ck_
    Participant

    @_ck_

    You have to edit the forum.php in your theme’s template.

    Are you using the built in Kakumei theme or have you already changed it?


    755628
    Inactive

    I have already changed it.

    Here is my forum.php:

    http://pastebin.com/m3c1eab2b

    I appreciate the help!


    _ck_
    Participant

    @_ck_

    Here you go:

    http://pastebin.com/m6e93abf8

    (you can copy the plain text from the lower part)

    The lines added are 49, 51 and 57.

    It’s untested but in theory should work.

    Let me know what happens.


    755628
    Inactive

    Hi,

    Okay, so I tried using the code. And it just makes every subforum and its subforums disappear. So everything is there, but with no links to any forums.


    chrishajer
    Participant

    @chrishajer

    Can you post the code you’re using at pastebin so we can take a look at what’s happening?


    755628
    Inactive

    The code that was on my original forum.php is

    http://pastebin.com/m3c1eab2b

    _ck_’s version that I tried using (it didn’t pop up any forums at all when I tried it) is

    http://pastebin.com/m6e93abf8


    _ck_
    Participant

    @_ck_

    Hang on while I double check the code, apparently I guessed wrong somewhere or missed something.

    update: perhaps it’s because $forum is not declared as a global in the template when when it loops through the forums it doesn’t see the changed parent.

    Try this update:

    http://pastebin.com/m3cef6607


    755628
    Inactive

    Hi,

    Now the subforums’ subforums show, but along with the subforums. It displays just like the original forum.php now. :(


    _ck_
    Participant

    @_ck_

    I just put the code on a test site and it works for me.

    Sub forums show, but not sub sub forums.

    You used http://pastebin.com/m3cef6607 ???

    The sub sub forums you are seeing are indented?

    Make sure you uploaded and are using the correct file.


    chrishajer
    Participant

    @chrishajer

    I uploaded that code to a test installation I have and it appears to work fine. Check it out:

    http://riversideinfo.org/bbpress-0902/


    755628
    Inactive

    Hi! Thank you _ck_ and chrishajer. It works wonderfully now.

    I have a few more questions if you don’t mind:

    1. Is there any way to optimize bbPress for extremely large forums? My forum will have 50 forums, followed by subforums for cities, followed by 5 subforums for each city. (I’ve thought it over through as well, and this is the best way to organize it)

    2. If there isn’t, is there a way I can create 50 forums that are different, one for each state, and have them running congruently? Would that alleviate the loading time and the strain on the database?

    3. Is there any way to have many separate forums that are sharing the same users table? They are going to be separate forums. I just want to have it so that 1) if one person is logged into one bbpress, they are also logged into another, and 2) if they are registered on one, they are also registered at another. Is there a way to do this?

    What would be the best way to handle this? It’s just that when I release the site, I want to have every section and everything up so that I don’t have to worry about expanding. I just want to do everything now (and having a lot of free time during the summer doesn’t hurt either!)

    Thanks.


    chrishajer
    Participant

    @chrishajer

    You might want to start a new topic for that new topic, now that you have the subforums thing sorted.

    You situation sounds like this one from a while ago

    https://bbpress.org/forums/topic/how-do-i-do-this

    I am not sure what the best way to do it is. Did you try making the forums and subforums all in one forum installation, and see what the actual loading time is? That would be easiest for user login integration I think.

    Can you imagine updating 50 forum installations?


    chrishajer
    Participant

    @chrishajer

    It’s too bad the pastebin code is no longer available. :-(

    True d’at. Although I think this may be what _ck_ was working on… I see the global declaration in there… I’ll try it…

    Nope. All fora disappear. I’ll look into where this $forum_id comes from…I’m learning.

    Huh. Setting $forum_parent=0; (or $forum_id = 0;) seems to do what I want. Hardcoding. Yuck.

    Yeah, I like that. I guess a template option for show/supress child fora would be better. Then you could use that db option…

    I’m still choosing templates but will work on it.

    This is what I had based on _ck_’s snippets:

    The theme’s front-page.php just after the forum list titles:

    </tr>
    <?php $forum_id = 0; //musnake: supress child fora: https://bbpress.org/forums/topic/hiding-subforums-subforums-from-subforum-pages#post-20150 ?>
    <?php $forum_parent=$forum_id; //musnake ?>
    <?php while ( bb_forum() ) : ?>
    <?php if ($GLOBALS['forum']->forum_parent==$forum_parent) { //musnake ?>

    <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 echo $GLOBALS['forum']->views; ?></td>
    <td class="num"><?php forum_posts(); ?></td>
    </tr>
    <?php } //musnake ?>
    <?php endwhile; ?>
    </table>
    <?php endif; // bb_forums() ?>

    That theme didn’t have the breadcrumbs I wanted, so after much searching (including PHPXref!) I found this: which gets put in your theme’s forum.php:

    <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> <?php bb_forum_bread_crumb(); ?></h3>

    Hope that helps. Thanks All.

    Oh, just to be clear, the //musnake are to point out where the changes are, not to claim any credit!


    sockmoney
    Member

    @sockmoney

    Good suggestion CK, worked like a charm!

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