Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbPress loop help

  • Hi I have the following code:

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

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

    <div class="box">

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

    <h3><a href="<?php forum_link(); ?>"><?php forum_name(); ?></a></h3>

    <?php continue; endif; ?>

    <ol>

    <li class="arrow f_unread">
    <a href="<?php forum_link(); ?>">
    <strong><?php forum_name(); ?></strong><br />
    <?php forum_topics(); ?> Topics / <?php forum_posts(); ?> Replies
    </a>
    </li>

    </ol>

    </div>

    <?php endwhile; ?>

    <?php endif; // bb_forums() ?>

    Struggling to get it to work how I want which is basically like this:

    for each category do this:

    <div class="box">
    <h3>CAT</h3>
    <ol>
    <li>Forum</li>
    <li>Forum</li>
    </ol>
    </div>

    so that div should be repeated for each block. if a set of forums has not category, then all of the code would be above would run but just no h3.

    so an example might look like this:

    <div class="box">
    <h3>CAT</h3>
    <ol>
    <li>Forum</li>
    <li>Forum</li>
    </ol>
    </div>

    <div class="box">
    <h3>CAT</h3>
    <ol>
    <li>Forum</li>
    <li>Forum</li>
    </ol>
    </div>

    <div class="box">
    <ol>
    <li>Forum</li>
    <li>Forum</li>
    <li>Forum</li>
    <li>Forum</li>
    </ol>
    </div>

    <div class="box">
    <ol>
    <li>Forum</li>
    <li>Forum</li>
    <li>Forum</li>
    <li>Forum</li>
    </ol>
    </div>

    can anyone help thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • I’m trying the same thing but instead of OL i’m using TABLES. http://bbpress.org/forums/topic/if-forum-is-not-category

    Maybe that can help you jumpstart to find the answer.


    kevinjohngallagher
    Member

    @kevinjohngallagher

    There’s a more fundamental issue here.

    Basically, you should ensure that every forum has a parent category. It solves so many issues when building themes and dealing with the loop. I covered this in my “bbPress as phpBB” theme back in 2008. I’ll hunt out the links for you. It was simple, but a bit of a pain.

    Okay changed all forums to have cats, but I need each block of forums with a cat to have this setup:

    <div class="box">
    <h3>CAT</h3>
    <ol>
    <li>Forum</li>
    <li>Forum</li>
    </ol>
    </div>

    At the moment it’s repeating the div and ol for each forum and not containing the forums within a cat inside just one div and ol.

    ALSO

    But because I have categories within categories it will become messy nested. So I only want to show top level forums and not the sub-forums/cats within.

    @kevinjohngallagher

    I missed read you post earlier. Yeah getting bbPress to display like phpBB would be an awesome starting ground for me. If you could find those files/links that would be much appreciated.

    Okay here is how I want it to work:

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

    <!-- FOR EACH TOP LEVEL CATEGORY BUILD A DIV WITH A H3 AND OL -->

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

    <div class="box">

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

    <h3><a href="<?php forum_link(); ?>"><?php forum_name(); ?></a></h3>

    <?php endif; ?>

    <ol>

    <!-- FOR EACH FORUM BUILD A LI (only show top level children not children within those) -->

    <li class="arrow f_unread">
    <a href="<?php forum_link(); ?>">
    <strong><?php forum_name(); ?></strong><br />
    <?php forum_topics(); ?> Topics / <?php forum_posts(); ?> Replies
    </a>
    </li>

    </ol>

    </div>

    <?php endwhile; ?>

    <?php endif; // bb_forums() ?>

    I only want top level cats and forums to show on the front page, clicking on those will show the sub-forums when you view in the individual forums.

    Can anyone help?

    From what I can tell it’s gonna require a foreach statement to do what I want.


    psycheangels
    Member

    @psycheangels

    @psycheangels

    Looks like some of that code could be useful. I’m not a PHP whizz though. Would you or anyone else be able to help me *rewrite* it to what I am wanting to do above?

    Much appreciated.

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

You must be logged in to reply to this topic.