Info
- 9 posts
- 3 voices
- Started 2 years ago by chandersbs
- Latest reply from mwaterous
Including a static file in your bb template
-
- Posted 2 years ago #
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");?> -
- Posted 2 years ago #
Slight difference between
bb_load_template()andinclude(),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 usinginclude()the included file just inherits all the global variables from the parent. -
- Posted 2 years ago #
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?
-
- Posted 2 years ago #
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') ); };)
-
- Posted 2 years ago #
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.
-
- Posted 2 years ago #
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
-
- Posted 2 years ago #
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...
-
- Posted 2 years ago #
Wow, it worked.
This is the code I used:
<?php if (get_forum_id() == 29): ?>
<?php bb_load_template('filename.php');?>
<?php endif; ?> -
- Posted 2 years ago #
Tis magic. ;)
-
You must log in to post.