MyBB Community Forums

Full Version: Include your custom pages in Mybb
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Hi,

If I make a custom page, how can I make it my starting page?

thank you
Excellent guide: an answer to my prayers
Hi,

How can I make a custom page paginated?

Thanks
An excellent guide, which has helped me a lot in the production of my site!
To include PHP into your custom page without using <iFrame> what is required is that you evaluate your PHP code within your custom.php page before the page is built.... for example here my custom.php page which queries a database and places the results into a table... the code with the results in is stored in a PHP variable called $content..
<?php
$content = "<table width=\"800\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\" class=\"tborder\"><thead><tr><td class=\"thead\" width=\"200\">Server IP & Port</td><td class=\"thead\" width=\"400\">Server Name</td><td class=\"thead\" width=\"200\">Date Added</td></tr><tbody>";

$conn = mysql_connect("localhost","database","password");

$sql = "SELECT * FROM table ORDER BY data DESC";

$result = mysql_db_query("database",$sql,$conn);

while($row = mysql_fetch_array($result))
  {
  $content .= "<tr><td class=\"trow1\">".$row['address']."</td><td class=\"trow1\">".$row['data']."</td><td class=\"trow1\">".$row['date']."</td></tr>";
  }

$content.="</tbody></table>";

// From here the custom page is no different that that provided by the originator of the thread

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

add_breadcrumb("Custom", "custom.php"); // (2)

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

Within the template where I want to see my dynamically generated content I use the {$content} reference variable... for example my template content might look like...

<html>
<head>
<title>{$mybb->settings[bbname]}</title>
{$headerinclude}
</head>
<body>
{$header}
<table width="100%" border="0">
<tbody>
{$content} <- Here is where your PHP results will be inserted
</tbody>
</table>
{$footer}
</body>
</html>

When everything is complete you should end up with something like this...

I hope I've explained this well enough on how to get dynamic PHP content into your custom pages without using <iFrame>
This apparently does not work with MyBB 1.4
Any ideas?
http://www.x-ind.com/board/tos.php
(2008-07-31, 11:27 PM)Schmarvin Wrote: [ -> ]This apparently does not work with MyBB 1.4
Any ideas?
http://www.x-ind.com/board/tos.php

It worked for me! Undecided
Brilliant tutorial. Always a bit unsure on how to do this, but this explains it in a clear and simple way. Smile
(2008-07-31, 11:27 PM)Schmarvin Wrote: [ -> ]This apparently does not work with MyBB 1.4
Any ideas?
http://www.x-ind.com/board/tos.php


It definitely works (with no modification) on 1.4.0 & 1.4.1

See here...
So if I have a forum on my root directory and want to create a custom page at /directory1/custompage.php, how should I change the code in the rules.php page? require "./global.php"; doesn't work and I tried a number of other combinations as well with no success.

Please advise. Thanks.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14