MyBB Community Forums

Full Version: Having a New Page use MYBB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I wanted to build a new page that uses MyBB. So far I have:
<?php
define("IN_MYBB", 1);
define('THIS_SCRIPT', 'groups.php');
require("global.php");
echo "<body style='background-color:#000077; color:white'>$username<br />";
$query="SELECT * FROM mybb_users WHERE username='$username'";
mysql_query($query);
$userinfo=mysql_query($query);
$num=mysql_numrows($userinfo);
$group=mysql_result($userinfo,0,"usergroup");
/*Build the navbar*/
if ($num<1)
{
echo "<a href='/usercp.php'>User CP - </a>";
     if ($group==3 || $group==4 || $group==6)
     {
      echo "<a href='/modcp.php'>Mod CP - </a>";
     }
     if ($group==4 || $group==3)
     {
      echo "<a href='/admincp.php'>Admin CP</a>";
     }
}
/*More things specific to what the page does.*/
?>

I added groups.php to the array $valid on global.php because I thought I was supposed to. The only link that shows up is User CP. I also need to know how to put the Powered By MyBB notice at the bottom of the page. On all the default pages the notice prints fine. Sorry if I am posting this in the wrong section.
You can use the Page Manager plugin and let that handle everything for you. If you don't want to use that, you need to tell us where you want the file to reside relative the forums. In the forum folder, outside the forum folder, etc?

For my custom pages, I use the following code at the top (edited for specif use of course)

<?php
/**
 * 
 * $Id: tech.php  $
 */

define("IN_MYBB", 1);
define("IN_TECH", 1);
$current_dir = getcwd();

// set the path to your images linked in articles (use {techimgdir}/image.jpg in article 
$techimgdir = "./techimg";


// set the path to your forums directory here (without trailing slash)
$forumdir = "./board";

//change working directory to allow board includes to work
$forumdirslash = $forumdir."/";
$change_dir = "./";

if(!@chdir($forumdir) && !empty($forumdir))
{
	if(@is_dir($forumdir))
	{
		$change_dir = $forumdir;
	}
	else
	{
		die("\$forumdir is invalid!");
	}
}

//include board files
require_once $change_dir."/global.php";
require_once MYBB_ROOT."inc/functions.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_user.php";
require_once MYBB_ROOT."inc/class_parser.php";

//change directory back to current where script is
@chdir($current_dir);

$templatelist = "add_a_page";


global $theme, $templates;

$theme['imgdir'] = $forumdirslash.substr($theme['imgdir'],0);
$theme['imglangdir'] = $forumdirslash.substr($theme['imglangdir'],0);

// Load global language phrases
$lang->load("tech");

//init time
$dateline = time();

/* URL Definitions */
if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1))
{
	define('TECH_URL', "tech.php");
	define('TECH_URL_PAGED', "tech-page-{page}.html");
	define('TECH_URL_ARTICLE', "tech-article-{aid}.html");
	define('TECH_URL_ARTICLE_PAGED', "tech-article-{aid}-page-{page}.html");
}
else
{
	define('TECH_URL', "tech.php");
	define('TECH_URL_PAGED', "tech.php?page={page}");
	define('TECH_URL_ARTICLE', "tech.php?article={aid}");
	define('TECH_URL_ARTICLE_PAGED', "tech.php?article={aid}&page={page}");
}

define('PROFILE_URL', $forumdir.PROFILE_URL);

//add initial breadcrumb
$navbits = array();
add_breadcrumb($lang->nav_tech, TECH_URL);

then I put all my own code below that to do what I need. Not only perform the queries, actions, etc, you need to populate the page content which gets output at the end. in this example, the code I create would generate content in a variable called $tech_main

finally end with

output_page($tech_main);

I suggest you look at the portal.php file and see how that works.
I'd rather not use a Plug-In. I want it to be in the /forums folder. The page name is to be groups.php .