2009-06-12, 03:52 PM
(This post was last modified: 2012-08-04, 03:46 PM by Infranight.)
Section I. Introduction
Many people have wondered, how do you make your own custom MyBB Page?
Well, it is actually quite simple, you just need to know the trick.
I'll be borrowing zaher1988's tutorial in this one.
Along with that, is dvb's tutorial and Yumi's PHP in Templates and Template Conditionals plugin.
So please note that I used their tutorials to help make this one, it was absolutely not made alone.
I just combined a few of my own knowledge and combined it with theirs'.
Section II. Creation of PHP File
First off, you need create a PHP file.
Open up notepad and paste the following:
It's the Discuss Admin » [Your Page Name] Part.
Also change the "example.php" to what your PHP file is called.
Then, change every other example to your file name, but without the php extension.
Section III. Creation of Template File
Now, go to your Global Templates and create a template file titled whatever your PHP file is without the extension.
So, in this case, it's "example" (remember, no uppercase if it was not used before!)
Inside, paste the following:
In between "<!-- Content: Start -->" and "<!-- Content: End -->" is what will show up to your users (aside from the header and footer)
Section IV. Adding Your Content
Like stated before, your content is displayed in between "<!-- Content: Start -->" and "<!-- Content: End -->".
For a table, paste the code between the two "tags":
Next, replace the "Example Page Content" with the content you need.
Refer to the mini HTML guide at the end of this tutorial for help.
Section V. User Permission
First off, you need to download the PHP in Templates and Template Conditionals plugin, written by Yumi, a.k.a., ZiNgA BuRgA
It will let you use PHP conditionals in your templates, which is what separates different user groups from each other, amongst other things.
If only members can view:
This is only applicable if your are using tables as your basic structure.
Section VI. Who's Online
After making the page, you need to make it more professional but adding it to the Who's Online Page (replacing the "Unknown Location Link").
First, open up inc/functions_online.php.
Find:
Add BEFORE:
Next, still keeping the file open, find:
Add before that:
For the "Viewing..." part, you can replace it with the message you want displayed. (remember, if you are using and words/conjunctions like can't, I'm, etc, you need to add a \ before the apostrophe)
If you wish to follow my example, then change "example.php" to your PHP file name (complete, with extension) and change the Example Page to the navigation bit.
Section VII. Mini HTML Guide
Bolded Text:
Hyperlink (open in same window):
Hyperlink (open in new window):
Div (id, which is started with a #):
Div (class, which is started with a .):
Image:
Space (vertical):
Space/Indent (horizontal):
Section VIII. Credits
Of course, I'd like to thank you guys for actually taking the time to read this long and dreadfully boring tutorial.
Again, I would like to thank zaher1988, Yumi, and dvb for their wonderful tutorials.
Thanks!
This tutorial is copyrighted to Changry
Many people have wondered, how do you make your own custom MyBB Page?
Well, it is actually quite simple, you just need to know the trick.
I'll be borrowing zaher1988's tutorial in this one.
Along with that, is dvb's tutorial and Yumi's PHP in Templates and Template Conditionals plugin.
So please note that I used their tutorials to help make this one, it was absolutely not made alone.
I just combined a few of my own knowledge and combined it with theirs'.
Section II. Creation of PHP File
First off, you need create a PHP file.
Open up notepad and paste the following:
<?php
define('IN_MYBB', 1);
require "./global.php";
add_breadcrumb("Example Page", "example.php");
eval("\$example = \"".$templates->get("example")."\";");
output_page($example);
?>
Replace "Example Page" with the navigation name you want.It's the Discuss Admin » [Your Page Name] Part.
Also change the "example.php" to what your PHP file is called.
Then, change every other example to your file name, but without the php extension.
Section III. Creation of Template File
Now, go to your Global Templates and create a template file titled whatever your PHP file is without the extension.
So, in this case, it's "example" (remember, no uppercase if it was not used before!)
Inside, paste the following:
<html>
<head>
<title>{$mybb->settings[bbname]} - Example Page</title>
{$headerinclude}
</head>
<body>
{$header}
<br />
<!-- Content: Start -->
<!-- Content: End -->
{$footer}
</body>
</html>
Change the Example Page to whatever you named your navigation bit (refer to the PHP file).In between "<!-- Content: Start -->" and "<!-- Content: End -->" is what will show up to your users (aside from the header and footer)
Section IV. Adding Your Content
Like stated before, your content is displayed in between "<!-- Content: Start -->" and "<!-- Content: End -->".
For a table, paste the code between the two "tags":
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr><td class="thead"><strong>Example Page</strong></td></tr>
<tr><td class="trow1">
<span class="smalltext">
Example Page Content
</span>
</td></tr>
</table><br>
Replace the Example Page with your navigation bit.Next, replace the "Example Page Content" with the content you need.
Refer to the mini HTML guide at the end of this tutorial for help.
Section V. User Permission
First off, you need to download the PHP in Templates and Template Conditionals plugin, written by Yumi, a.k.a., ZiNgA BuRgA
It will let you use PHP conditionals in your templates, which is what separates different user groups from each other, amongst other things.
If only members can view:
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr><td class="thead"><strong>Example Page</strong></td></tr>
<tr><td class="trow1">
<if $mybb->user['uid'] then>
<span class="smalltext">
Example Page Content
</span>
<else />
<span class="smalltext">
<strong><a href="member.php?action=login">Login</a> or <a href="member.php?action=register">Register</a></strong>
</span>
</if>
</td></tr>
</table><br>
Replace "Example Page Content" once again with the text you filled in with before.This is only applicable if your are using tables as your basic structure.
Section VI. Who's Online
After making the page, you need to make it more professional but adding it to the Who's Online Page (replacing the "Unknown Location Link").
First, open up inc/functions_online.php.
Find:
default:
$user_activity['activity'] = "unknown";
break;
}
$user_activity['location'] = htmlspecialchars_uni($location);
$plugins->run_hooks_by_ref("fetch_wol_activity_end", $user_activity);
return $user_activity;
}
Add BEFORE:
case "example":
$user_activity['activity'] = "example";
break;
Replace both "example" with your PHP file name, without the PHP extension.Next, still keeping the file open, find:
}
$plugin_array = array('user_activity' => &$user_activity, 'location_name' => &$location_name);
$plugins->run_hooks_by_ref("build_friendly_wol_location_end", $plugin_array);
if($user_activity['nopermission'] == 1)
{
$location_name = $lang->viewing_noperms;
}
if(!$location_name)
{
$location_name = $lang->sprintf($lang->unknown_location, $user_activity['location']);
}
return $location_name;
}
Add before that:
case "example":
$location_name = 'Viewing <a href="example.php">Example Page</a>.';
break;
Change the first "example" to what you set your previous case to, which is supposed to be your PHP File name with the extension, if you're using my recommended method. For the "Viewing..." part, you can replace it with the message you want displayed. (remember, if you are using and words/conjunctions like can't, I'm, etc, you need to add a \ before the apostrophe)
If you wish to follow my example, then change "example.php" to your PHP file name (complete, with extension) and change the Example Page to the navigation bit.
Section VII. Mini HTML Guide
Bolded Text:
<strong>
TEXT
</strong>
Hyperlink (open in same window):
<a href="LINK">LINKNAME</a>
Hyperlink (open in new window):
<a href="LINK" target="_blank>LINKNAME</a>
Div (id, which is started with a #):
<div id="DIVNAME">
CONTENT
</div>
Div (class, which is started with a .):
<div class="DIVNAME">
CONTENT
</div>
Image:
<img src="IMGLINK" />
Space (vertical):
<br */>
remove the * firstSpace/Indent (horizontal):
Section VIII. Credits
Of course, I'd like to thank you guys for actually taking the time to read this long and dreadfully boring tutorial.
Again, I would like to thank zaher1988, Yumi, and dvb for their wonderful tutorials.
Thanks!
This tutorial is copyrighted to Changry