Skip to:
Content
Pages
Categories
Search
Top
Bottom

Best practices for adding a sidebar to bbPress

  • I’m working on my first bbPress theme and I am going to have two columns on most pages. I will likely vary the content of this second column depend on which page you are on.

    I’d like to use a separate sidebar just like WordPress so that I can create a few different files that I could load.

    These sidebars need not draw any content from WordPress, I don’t need deep integration or anything. I’m just wondering what would be the best way to go about doing this.

    Theme Playground’s bbPress forum has it’s sidebar added to the footer.php file, which sounds like a good idea, but seems a bit impractical for multiple sidebars.

    I also found this simple sidebar plugin in the forums which adds the “bb_get_sidebar()” function to bbPress. A neat idea, but I hate to frivolously add extra plugins, especially when it is essential for the theme to work properly.

    So what I have done in my theme is to simply use an include like this:

    <?php include ('sidebar.php'); ?>

    This has been working fine for me and I don’t see any reason not to do it like this.

    But does anyone else have a different method that has some advantage? Or is there plans for, or already an official function like “bb_get_sidebar()” that I am unaware of?

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

  • _ck_
    Participant

    @_ck_

    Using include is fine and fastest. Remember to try to load the sidebar AFTER your content if you care about things like SEO where content should come first. This would imply doing the include in the footer and floating the main content left and the sidebar right (or visa versa).

    Nice work on your theme, seamlessly integrated.

    Thanks for the info _ck_, glad to hear that I’m not way off track.

    Yeah, I have been loading the sidebar after the content, but just above the footer include, rather than in the footer, so that I can use different sidebars easily.

    I wouldn’t want to take credit for Ryan Imel’s work! Only linked to Theme Playground as an example, but you’re right, he did an awesome job on integrating the forums into the rest of his site.

    Now that I scroll down and read the comments on his post a little closer, I see that Justin Tadlock mentioned another way to add a sidebar, but it looks to have the same end result as a regular include:

    require_once( bb_get_template( 'sidebar.php' ) );

    I’m not sure if I can match Ryan’s quality design, but I’m going to try to do a few fresh looking bbPress themes to share with the community.


    _ck_
    Participant

    @_ck_

    Doing it through bb_get_template simply fires an extra filter – but nothing else is aware of sidebars in bbPress yet so it’s pointless. Plus I wasn’t aware you could use require on a function. Then bb_get_template uses another include/require so it’s massive overkill (or just wrong in the first place).

    That makes sense, I’ll stick with a vanilla include then, I’d rather have my themes be fast and simple.


    LizFilardi
    Member

    @lizfilardi

    Hey,

    I’ve followed this forum and included the following code:

    function add_sidebar() {
    include ('sidebar.php');
    }
    add_filter('bb_foot', 'add_sidebar');

    But how do I get this sidebar to fit into the main div?

    Thanks.


    chrishajer
    Participant

    @chrishajer

    You have to resize the other divs to make it fit. That can all be done in the style.css. You might make the overall layout wider or narrow up some of the columns to allow your sidebar to fit.

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