MyBB Community Forums

Full Version: Howto make extra page !
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hmm is there any way that someone can guide me through making extra page in mybb ... you know to have header and everything and content where forums usually start !

Hope you understand ....
Make Custom Pages - MyBB 1.2 (updated from zaher's guide)


1. Design your page using simple HTML
<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<thead>
<tr>
<td class="thead"><strong>RULES</strong></td>
</tr>
<tbody>
<tr>
<td class="trow1"><p align="center">My RULES</p></td>
</tr>
</tbody>
</table>
{$footer}
</body>
</html>

2. Go to Admin CP > Templates > Modify / Delete > Expand > Add Template - name it rules & insert the code above.

3. Lets make a new php file now, and call it rules.php & put the following code in it
<?php
define("IN_MYBB", 1); 

require "./global.php"; // (1)

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

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

(1) You should never remove it because we need to to connect to the DataBase to retrieve templates, to display the header and footer etc...

(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.

A demo is available here.
great thanks for this !
I needed to also add a line to get this to work.

$templatelist = "rules";

Add that after this line

define("IN_MYBB", 1);
Well, that's not actually needed, shouldn't be, but it lowers the query count of MyBB. Smile
Please double check that CraKteR for 1.2...for me I couldn't create a page without that line.
I can confirm what CraKteR said, You do not need the $templatelist.. But it doesn't hurt to have it.
The template lists tell the template class which templates it should cache on start-up. When the get function is called it checks if the template is set, if it's not it runs a query to retrieve it. Smile
Hmm..I wonder then if I had a conflict with caching yesterday then. Oh well...like you said this saves a query and it should be good practice.

Thank you all for the replies and the tutorial.
i turned caching off because with it you have to refresh the index to see anything new (as well as posts and things like that)
Pages: 1 2