MyBB Community Forums

Full Version: Add Forum to Custom Page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I created a custom .php page for my site and wanted to add my forum onto the page.  However, when I place the param {$forums} to the html template, nothing shows up.  Is there something that I am missing? 

Thank you.
variables do not function globally. {$forums} works on index template - not at other places.
Is there a way to make the {$forums} variable work globally?
I am not sure what you are trying to do, but I recommend you to turn the forum into the page than adding it inside a page.

If you disagree, maybe this link is going to help you to turn your page part of MyBB: http://community.mybb.com/thread-116043.html
Please try this


$templatelist = "forumbit_depth1_cat,forumbit_depth2_cat,forumbit_depth2_forum,forumbit_depth1_forum_lastpost,forumbit_depth2_forum_lastpost";

require_once MYBB_ROOT.'inc/functions_forumlist.php';
require_once MYBB_ROOT.'inc/class_parser.php';
$parser = new postParser;

$plugins->run_hooks('index_start');

// Load global language phrases
$lang->load('index');

if($mybb->user['uid'] == 0)
{
 // Build a forum cache.
 $query = $db->simple_select('forums', '*', 'active!=0', array('order_by' => 'pid, disporder'));

 $forumsread = array();
 if(isset($mybb->cookies['mybb']['forumread']))
 {
 $forumsread = my_unserialize($mybb->cookies['mybb']['forumread']);
 }
}
else
{
 // Build a forum cache.
 $query = $db->query("
 SELECT f.*, fr.dateline AS lastread
 FROM ".TABLE_PREFIX."forums f
 LEFT JOIN ".TABLE_PREFIX."forumsread fr ON (fr.fid = f.fid AND fr.uid = '{$mybb->user['uid']}')
 WHERE f.active != 0
 ORDER BY pid, disporder
 ");
}
while($forum = $db->fetch_array($query))
{
 if($mybb->user['uid'] == 0)
 {
 if(!empty($forumsread[$forum['fid']]))
 {
 $forum['lastread'] = $forumsread[$forum['fid']];
 }
 }
 $fcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
$forumpermissions = forum_permissions();

$permissioncache['-1'] = '1';
$bgcolor = 'trow1';

// Decide if we're showing first-level subforums on the index page.
$showdepth = 2;
if($mybb->settings['subforumsindex'] != 0)
{
 $showdepth = 3;
}

$forum_list = build_forumbits();
$forums = $forum_list['forum_list'];

$plugins->run_hooks('index_end');

echo "
<script type=\"text/javascript\">
<!--
 lang.no_new_posts = \"{$lang->no_new_posts}\";
 lang.click_mark_read = \"{$lang->click_mark_read}\";
// -->
</script>
<br class=\"clear\" />
{$forums}

<br class=\"clear\" />
";