MyBB Tutorials

Add Custom PHP Pages

Submitted by e8iw2f3, , Thread ID: 28

Thread Closed

RE: Add Custom PHP Pages

#2
What I like to do on creating new pages is having a few variables. Title and content are the most important of course. You can even eval() the title variable to use as the content box title too, like such:
What I like to do on creating new pages is having a few variables. Title and content are the most important of course. You can even eval() the title variable to use as the content box title too, like such:
PHP Code:
<?php 

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

$page_title "Page title";

$content "Some random content";
add_breadcrumb($page_title"somename.php"); 

eval(
"\$page_title =\""$page_title "\";");
eval(
"\$content =\""$content "\";");
eval(
"\$html = \"".$templates->get("template_name")."\";"); 


output_page($html);

?>

Template:
Code:
<html>
<head>
<title>Your title here</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="1" cellpadding="4" class="tborder">
<tr>
<td class="thead"><span class="smalltext"><strong>{$page_title}</strong></span></td>
</tr>
<tr>
<td class="trow1">

{$content}

</td></tr></table>
{$footer}
</body>
</html>
Then you could rename the template to something like "main_container" and reuse it throughout multiple pages.

Users browsing this thread: 1 Guest(s)