MyBB Community Forums

Full Version: Add new custom PHP page.
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
Sad Anyone want to help me?

Edit: Got Xenforo. I gave up on mybb.
(2012-04-04, 11:57 AM)crazy4cs Wrote: [ -> ]I didn't found some good ones floating around. So here is how I create them and here is how you can create them.

Its quite easy. Heres how you do.

First create, somepage.php file. Inside it, paste below code and save it:

<?php 

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

add_breadcrumb("Title here", "somename.php"); 

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

output_page($html);

?>

Next, Themes & templates > Templates > Global Templates > Add template.

Add below example template:

<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>Your title here.</strong></span></td>
</tr>
<tr>
<td class="trow1">

Add here your custom messages.

</td></tr></table>
{$footer}
</body>
</html>

And for title, give any title to it but make sure you enter same title name in the somename.php file where it is calling (evaluating eval) the template name. As in this example case, you should enter title as template_name since we entered and recalled same global template in somename.php file.

Save the global template and it should work fine now.

Thanks for this tutorial. I tried a whole lot of different tuts for this and none of them worked. This one however, did and I thank you for sharing this.
One question. I got my page up with images, and everything works fine but let's say I wanted to round the corners for my main table, how does one go about that? I tried adding a border radius to several different things but none worked so I'm asking for help on this one.
I've read tuts about adding IMG corners in separate cells but that just seems like too much of a hassle and a lot of jotting things around to get them to work right. I don't want to deal with that. Big Grin
Quote:One question. I got my page up with images, and everything works fine but let's say I wanted to round the corners for my main table, how does one go about that? I tried adding a border radius to several different things but none worked so I'm asking for help on this one.
Main table as in? Can you show in screenshot? Or you mean the table inside trow?
Yes, the table inside trow.
I have img bgs inside it and it looks bad IMO when my theme is all rounded but this table is not. Thank you.
Hello, this tutorial worked great, however I am confused on who I could insert PHP code into it. I am a bit new to the MYBB forum script, could someone please explain to me how I would insert PHP into my custom page?
What you wish to add? Everything could be added to it.
Nice tutorial. I have seen similar tutorials here on MyBB Community but they require plugins or are a bit complicated. I found this easy to use.

Edited

By the way, what if I want to add custom permissions, what code do I use?
You forget to add the template to the $templatelist variable, that will save you one query.
(2012-08-07, 09:44 PM)Omar G. Wrote: [ -> ]You forget to add the template to the $templatelist variable, that will save you one query.
Hmm, where?


(2012-08-07, 09:21 PM)kamz89 Wrote: [ -> ]By the way, what if I want to add custom permissions, what code do I use?
As in disallow certain groups to see the page? Then you can use something like this:

if(in_array($mybb->user['usergroup'], array('2','8')))
{
error("Access denied");
}

You can replace 2 and 8 with any groups you want to disallow seeing that page. You can also add more groups to it to disallow them in a similar fashion.
(2012-08-08, 05:38 AM)crazy4cs Wrote: [ -> ]
(2012-08-07, 09:44 PM)Omar G. Wrote: [ -> ]You forget to add the template to the $templatelist variable, that will save you one query.
Hmm, where?

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

Should be:
$templatelist = 'template_name';
define('IN_MYBB', 1); require "./global.php";
Pages: 1 2 3 4 5 6 7 8 9 10