Current time: 02-09-2010, 01:48 PM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 3 Votes - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comprehensive Guide to Custom Page Creation
06-12-2009, 03:52 PM
Post: #1
Comprehensive Guide to Custom Page Creation
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 Code:
<?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:
Code:
<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":
Code:
<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:
Code:
<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:
PHP Code:
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:
PHP Code:
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:
PHP Code:
}
    
    
$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:
PHP Code:
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:
Code:
<strong>
TEXT
</strong>

Hyperlink (open in same window):
Code:
<a href="LINK">LINKNAME</a>

Hyperlink (open in new window):
Code:
<a href="LINK" target="_blank>LINKNAME</a>

Div (id, which is started with a #):
Code:
<div id="DIVNAME">
CONTENT
</div>

Div (class, which is started with a .):
Code:
<div class="DIVNAME">
CONTENT
</div>

Image:
Code:
<img src="IMGLINK" />

Space (vertical):
Code:
<br */>
remove the * first

Space/Indent (horizontal):
Code:
&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 Discuss Admin

[Image: signature.png]
AF Marketplace | Zynge.net

PM me w/ your email to get invited to Lockerz
Visit this user's website Find all posts by this user
Quote this message in a reply
06-12-2009, 06:12 PM (This post was last modified: 06-12-2009 06:18 PM by Bilgecix.)
Post: #2
RE: Comprehensive Guide to Custom Page Creation
thanks..
i'll try to make it...
Find all posts by this user
Quote this message in a reply
06-12-2009, 07:20 PM (This post was last modified: 06-12-2009 07:56 PM by -Prowler-.)
Post: #3
RE: Comprehensive Guide to Custom Page Creation
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

Visit this user's website Find all posts by this user
Quote this message in a reply
06-18-2009, 11:18 AM (This post was last modified: 06-18-2009 11:18 AM by Jed K.)
Post: #4
RE: Comprehensive Guide to Custom Page Creation
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!
Find all posts by this user
Quote this message in a reply
06-18-2009, 12:19 PM
Post: #5
RE: Comprehensive Guide to Custom Page Creation
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...!

<font size too large, removed. use NORMAL size only, like below>
FIND OUT ABOUT MYBBCODES.COM
Visit this user's website Find all posts by this user
Quote this message in a reply
06-18-2009, 04:08 PM
Post: #6
RE: Comprehensive Guide to Custom Page Creation
Thanks, please note that I have used other's tutorials as well, as mentioned in the credits.

[Image: signature.png]
AF Marketplace | Zynge.net

PM me w/ your email to get invited to Lockerz
Visit this user's website Find all posts by this user
Quote this message in a reply
06-18-2009, 07:20 PM
Post: #7
RE: Comprehensive Guide to Custom Page Creation
(06-18-2009 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.

Visit this user's website Find all posts by this user
Quote this message in a reply
06-18-2009, 08:16 PM
Post: #8
RE: Comprehensive Guide to Custom Page Creation
He wants a sub directory though. he wants a site and a forum which some plugins and addons would conflict with.

Projects-
Need PHP/ASP.Net Hosting? Try CXR

Kirisute Gomen

Windows isn't a virus. At least a virus does something.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-19-2009, 04:08 AM
Post: #9
RE: Comprehensive Guide to Custom Page Creation
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!
Find all posts by this user
Quote this message in a reply
06-20-2009, 03:59 PM
Post: #10
RE: Comprehensive Guide to Custom Page Creation
Anyone?

Hey, Mr. Feather!
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: