Last Updated: February 25, 2016
·
8.605K
· penguinpaul

MyBB Custom Pages

A while back I shared how to make custom PHP pages that used MyBB's template: http://coderwall.com/p/71nr0q

Today, I'm here to tell you an even easier method to create and edit these pages.

Create a php file, name it whatever you want it to be named, and put these contents:

<?php 
    define('IN_MYBB', 1);
    require_once("global.php");

    add_breadcrumb("Page Title", $_SERVER['PHP_SELF']); 

    eval("\$page = \"".$templates->get("page_name")."\";"); 

    output_page($page);
?>

Replace "Page Title" with the title of your page, and replace "pagename" with a unique identifier for your page, such as "aboutus". If you want to prevent guests from seeing the page, find

require_once("global.php");

and replace with

require_once("global.php");
if($mybb->user['uid'] == 0)
    error_no_permission();

Next, head on over to the MyBB Admin Control Panel and go to "Templates & Style". Click "Templates", then "Global Templates". Create a new template and give it the name you gave it above, e.g. "about_us". For its contents, add this:

<html>
<head>
<title>Your title</title>
{$headerinclude}
</head>
<body>
{$header}
Your content here...
{$footer}
</body>
</html>

Replace the title and content with your page's title and content, then save the new template.

You're ready to go! Just access the page and the content will show up with the MyBB theme the member is using. Whenever you want to edit the page, you can now do so directly from the ACP instead of through the filesystem.

3 Responses
Add your response

Old but gold Paul :D

over 1 year ago ·

just what i needed :D thanks!

over 1 year ago ·

You're the King for this.

over 1 year ago ·