MyBB Community Forums
[How To?] Add Forum to Custom Page - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: 1.8 Support (https://community.mybb.com/forum-175.html)
+--- Forum: General Support (https://community.mybb.com/forum-176.html)
+--- Thread: [How To?] Add Forum to Custom Page (/thread-194448.html)



Add Forum to Custom Page - AndrewSP - 2016-06-20

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.


RE: Add Forum to Custom Page - .m. - 2016-06-20

variables do not function globally. {$forums} works on index template - not at other places.


RE: Add Forum to Custom Page - AndrewSP - 2016-06-20

Is there a way to make the {$forums} variable work globally?


RE: Add Forum to Custom Page - Hugop - 2016-06-22

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


RE: Add Forum to Custom Page - MrBrechreiz - 2016-06-23

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\" />
";