Homepage or frontpage

← General Stuff — Started 7 May, 2011

Hey, i was going to start a theme site for my themes with someone and i see alot of other places have a front page or homepage that display information on what kind of site they are and a welcome message and sometimes a logo and graphics and all that stuff, i was wondering how that could be made, i know it involves php, html and css, but im not really sure on how to approach it, thanks.
Hi,

Well, as you make themes, it's probably easier to just create templates for the front page (and any other page I guess). Here's a quick run down.

Make a template in the Global Templates called "homepage". Just write "Hello World" or something equally as quirky. Next up is the hard(ish) part - make a new PHP file in the root of your forum called "homepage.php", and save it with this structure:

PHP Code:
<?php
define
("IN_MYBB"1);
define('THIS_SCRIPT''homepage.php');

// A list of templates to cache onload
$templatelist "homepage";

// Require our global setup
require_once "./global.php";

eval(
"\$homepage = \"".$templates->get("homepage")."\";");
output_page($homepage);
?>

Now, when you visit the homepage.php file in your browser, you should see "Hello World" or whatever you've written. You then of course can use any variable in MyBB's global scope - including $headerinclude and $footer which makes it stupidly simple to make your homepage look like the forum.

You might have a different structure to your site - your forum may be in a subdirectory or a subdomain. In which case, you'll need to chdir to the point global.php in the right direction. In the code above, you'll need to add the following code before including global.php:

PHP Code:
chdir('./forums'); // Or whatever folder your forum is contained in 

You'll be well on your way then to making your site through MyBB. You can do really clever things here, like I do with Xekko, like adding a new stylesheet in the ACP and assigning it to the homepage's THIS_SCRIPT value. Smile
Thanks for this Tomm - very handy info Smile
[Image: leelink.gif]
Ahh, the clever part is of course including your own templates inside of templates. Consider doing something like this:

PHP Code:
$admin_options '';
if(
$mybb->usergroup['cancp'])
{
     eval(
"\$admin_options = \"".$templates->get("homepage_admin")."\";");
}

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

You can then put $admin_options inside the "homepage" template and have something that only Administrators are only supposed to see there. The possibilities are endless, but it could for example deliver different content to guests. Master this bit and you'll pretty much be able to follow all of MyBB's template system.

User(s) browsing this thread: 1 Guest(s)