D&D Forums - MyBB Plugins & Themes
Include your custom pages in MyBB - Printable Version

+- D&D Forums - MyBB Plugins & Themes (https://developement.design/forum)
+-- Forum: MyBB General Discussions (https://developement.design/forum/forumdisplay.php?fid=23)
+--- Forum: Tricks & Tutorials (https://developement.design/forum/forumdisplay.php?fid=11)
+--- Thread: Include your custom pages in MyBB (/showthread.php?tid=27958)



Include your custom pages in MyBB - AmazOuz - 09-27-2022

Hello there!


In case you have made a new page (e.g a rules page) and you'd like to use it along to MyBB! simply you will put a link to that page. but read this and you will have as a part of the board, with headers, navigation, footer etc....

Let's start.

1st design the page you want, let's make a simple page

Code:
<html>
<head>
<title>{$mybb->settings[bbname]}</title>
{$headerinclude}
</head>
<body>
{$header}
<br />
<table width="100%" border="0">
<thead>
<tr>
<th>RULES</th>
</tr>
<tbody>
<tr>
<td>Our rules</td>
</tr>
</tbody>
</table>
{$footer}
</body>
</html>

Now go to Admin CP > Templates > Modify / Delete > Expand "Global Templates" > Add template

Call it rules & put that code

Now we have hot a template, ready to be used in our new page. note that you customize that the way you want, call it the name you want, as long as you are keeping the unity.

Now let's make a new php file, let's call it rules.php

inside it put

PHP Code:
<?php

define
('IN_MYBB'1); // (1a)
require "./global.php"// (1b)

add_breadcrumb("Rules page""rules.php"); // (2)

eval("\$rules = \"".$templates->get("rules")."\";"); // (3)
output_page($rules); // (4)
?>

(1) is very important dont remove it, we need to to connect to the DB, to retrieve templates, to diplay the header and footer etc... , means it's our main part.

(2) is the navigation name, (e.g MyBB Community Forums / MyBB / General Support / New Thread ), so Rules page refers to what will appear Community Forums / Rules Page and rules.php is your page.

(3) from here we select which template, so replace rules with you custom name, in both parts.

(4) is the page that will output the template, same name of the template, however in case you have evaluated it with a different name in stage (3) use the evaluation call name, and not the template name.

Ok now like that , you can make a link to that page and it will appear as any other page in the board!

I hope you have enjoyed my tutorial, and that it was helpfull.

Source : https://community.mybb.com/thread-6615.html

Greets