Comprehensive Guide to Custom Page Creation
#1
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:
<?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 * first

Space/Indent (horizontal):
&nbsp;

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
Reply
#2
thanks..
i'll try to make it...
Reply
#3
Nice TUT!

Here's what it helped me wit Toungue (I opted to not include the who's online as it is just a rules page)


http://thegamingcore.net/rules.php
[Image: prowlersig.png]
Leave? I didn't leave...I just started lurking!
Reply
#4
How can I make a custom page appear on the who's online list if it's in its own directory?

For example, my forum is at http://www.myforum.com/
But my custom page is http://www.myforum.com/custom/index.php

Should I replace example with "custom" or with "index" or with something like "custom/index"? What happens if I have /custom/index.php AND /custom-2/index.php? How do I include both?

I tried replacing example with "custom" and "custom-2" but it didn't work.

Thanks.
Hey, Mr. Feather!
Reply
#5
Though their are alot of tutorial on that topic, yet your's is unique and very good for all types of members

Good Work Infra...!
Reply
#6
Thanks, please note that I have used other's tutorials as well, as mentioned in the credits.
Reply
#7
(2009-06-18, 11:18 AM)Jed K Wrote: How can I make a custom page appear on the who's online list if it's in its own directory?

For example, my forum is at http://www.myforum.com/
But my custom page is http://www.myforum.com/custom/index.php

Should I replace example with "custom" or with "index" or with something like "custom/index"? What happens if I have /custom/index.php AND /custom-2/index.php? How do I include both?

I tried replacing example with "custom" and "custom-2" but it didn't work.

Thanks.

O_o

Just put it on your ROOT mybb directory.
[Image: prowlersig.png]
Leave? I didn't leave...I just started lurking!
Reply
#8
He wants a sub directory though. he wants a site and a forum which some plugins and addons would conflict with.
I'm not here often, shoot a PM or whatever if you want my discord.
Reply
#9
I don't want to just "put it in my ROOT directory"

As T0m said, I am building a site out of MyBB and thus separate directories are needed for organization. Everything else works fine, but this is one thing I haven't been able to figure out how to configure properly, so if anyone can help I would really appreciate it. OP perhaps?
Hey, Mr. Feather!
Reply
#10
Anyone?
Hey, Mr. Feather!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)