Skip to:
Content
Pages
Categories
Search
Top
Bottom

Including a static file in your bb template

  • I’m running a forum, which has a sidebar on the left, it was a pain to edit that sidebar, so I tried some including today.

    If you want to including a file in to your forum, use this code:

    <?php bb_load_template(‘sidebar.php’);?>

    Add that sidebar.php or whatever you want to call it in your template folder.

    It works similar like the one we are used to using for WordPress:

    <?php include(TEMPLATEPATH.”/sidebar.php”);?>

Viewing 8 replies - 1 through 8 (of 8 total)
  • Slight difference between bb_load_template() and include(), bb_load_template() can take as it’s 2nd argument an array of containing the names of variables to be used as globals within the template, whereas using include() the included file just inherits all the global variables from the parent.

    I would really love to know the 2nd option, so i can place that code in my forum.php

    it would be nice to display a block of text when users visit some sections of my forum.

    but im not so good with statements, can u code an example?

    function login_form() {
    if ( bb_is_user_logged_in() )
    bb_load_template( 'logged-in.php' );
    else
    bb_load_template( 'login-form.php', array('user_login', 'remember_checked', 'redirect_to', 're') );
    }

    ;)

    Okay suppose I have a forum with id 12, I want to show a block of text that is in a file called text.php, whenever someone visits that forum (forum.php?id=12)

    How would write that then? And it doesn’t matter if the user is logged in or not.


    Mark
    Member

    @delayedinsanity

    get_forum_id()

    ie;

    <?php if (get_forum_id() == 12): ?>
    text block
    <?php endif; ?>

    A lot of these functions aren’t nearly as well documented as WordPress’ own similar functions, but can all be found inside of bb-includes/functions.bb-template.php

    Trick is for bbPress functions, half of them are WordPress functions, just sometimes with bb_ on the front, so they behave essentially the same. A fair few others are just aliases to return data instead of outputting it (i.e. get_forum_link vs. forum_link). Beyond that though, yeah it’s all pretty undocumented, but it’s usually relatively obvious from the name and parameters it takes.

    I’d love to be able to help right a bbPress Codex mind you…

    Wow, it worked.

    This is the code I used:

    <?php if (get_forum_id() == 29): ?>

    <?php bb_load_template('filename.php');?>

    <?php endif; ?>


    Mark
    Member

    @delayedinsanity

    Tis magic. ;)

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