MyBB Community Forums

Full Version: [HELP] MyBB 1.8 Login Splash Page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So basically I would like to turn this: 

[Image: alVlG5F.png]

into something like this:


[Image: smr11HI.png]



PART 1


I know the basics of PHP and Template editing, but I'm not sure where even to start with this. Should I make a new PHP file and redirect there? Or modifying the existing one?

Ok, so I read some things online and it seems what I want to do has been done, but there isn't really any documentation on it.

So, if this process is correct I need to first create a custom page using this guide: http://community.mybb.com/thread-6190.html

Then, since this file will be in the same directory as the forum, I need to follow this guide: http://community.mybb.com/thread-118512.html , in order to make sure that when users visit "index.php" they are redirected to my custom php page. (I would like to have it so that the PHP Page loads first, but I can figure that out later.)

I thought about renaming the "index.php" to something else so that I could have this customised login script as "index.php" and have it redirect to the renamed "index.php". (Using http://community.mybb.com/thread-69040.html) But, on second thought, that doesn't seem like a very good idea.

So, I will proceed to try to use the things outlined in these guides above. I'll use this thread for any bugs, support, and things like that. If you have anything that would help it would be greatly appreciated!

EDIT 2: So I tried using this code here to create a custom page:

<?php
chdir('.'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>
<?php

if($mybb->user['uid'])
{
// The user is logged in, say Hi
echo "Hey, $mybbuser[username].<br>
Thanks for logging in.";
}
else
{
// The user is not logged in, Display the form
echo "<form action='forums/member.php' method='post'>
Username: <input type='text' name='username' size='25' maxlength='30' /><br />
Password: <input type='password' name='password' size='25' />
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='index.php' />
<input type='submit' class='submit' name='submit' value='Login' /></form><br>";
}
?>

But it just shows the default mybb login page. So, I'm going to now search for how to implement just the form. Without "member.php" including the whole forum into just its login form.


EDIT 3: Removing "{$header}" & "{$footer}" from "Template -> Member Templates -> member_login" does nothing.

<html>

<head>
<title>{$mybb->settings['bbname']} - {$lang->login}</title>
{$headerinclude}
</head>
<body>

<br />
{$inline_errors}
{$member_loggedin_notice}
<form action="member.php" method="post">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->login}</strong></td>
</tr>
<tr>
<td class="trow1"><strong>{$lang->username}</strong></td>
<td class="trow1"><input type="text" class="textbox" name="username" size="25" style="width: 200px;" value="{$username}" /></td>
</tr>
<tr>
<td class="trow2"><strong>{$lang->password}</strong><br /><span class="smalltext">{$lang->pw_note}</span></td>
<td class="trow2"><input type="password" class="textbox" name="password" size="25" style="width: 200px;" value="{$password}" /> (<a href="member.php?action=lostpw">{$lang->lostpw_note}</a>)</td>
</tr>
<tr>
<td class="trow1" colspan="2" align="center"><label title="{$lang->remember_me_desc}"><input type="checkbox" class="checkbox" name="remember" checked="checked" value="yes" /> {$lang->remember_me}</label></td>
</tr>
{$captcha}
</table>
<br />
<div align="center"><input type="submit" class="button" name="submit" value="{$lang->login}" /></div>
<input type="hidden" name="action" value="do_login" />
<input type="hidden" name="url" value="{$redirect_url}" />
</form>

</body>
</html>

Where is the code that displays the header and footer for the login page? Is it hard-coded in "member.php"?
[/spoiler]

EDIT Before Sleep: So I searched practically all the templates. Nada. The only that leaves me with is that it's hardcoded into "member.php". Removing it will be a daunting task. So, going to rest my head. Hopefully someone replies tomorrow morning! 





Alright, so I woke up this morning and did some more digging around. It seems I needed to create my own template as a part of the theme and make a php file similar to this in "login.php":


<?php 

define('IN_MYBB', 1); require "./global.php";
//Check if the user is logged in
if(!$mybb->user['uid'])
{
	//Redirect to Home Directory/index page
	redirect("index.php", $lang->redirect_loggedin);
}
else
{
		eval("\$html = \"".$templates->get("login_splash")."\";"); 

output_page($html);

}
	?>

It seems, I've reached the word limit for one post! So, Basically, as I'm typing this out for the third time before realizing. The TL;DR.

If the user is logged in, the login page displays this: (http://i.imgur.com/YhTV0q4.png)
If the user is not logged in, the page shows the standard myBB default login. Which is not what I want. Is there a way to disable the default login page on certain pages in php? Will update upon successful progress!

Made a simple change to the above code. Instead of checking for the UID, it now checks for an existing Cookie.

<?php 

define('IN_MYBB', 1); require "./global.php";
//Check if the user is logged in
if ( $_COOKIE['mybbuser'])
{
	//Redirect to Home Directory/index page
	redirect("index.php", $lang->redirect_loggedin);
}
else if (!$_COOKIE['mybbuser'])
{
		eval("\$html = \"".$templates->get("login_splash")."\";"); 

output_page($html);

}
	?>
do not understand a..@:£$£"£ Sad , can some one please make tutorial how exactly make this happen in 1.8* mybb
I would just edit the existing login page and remove everything around the login code, except the logo.
(2015-02-25, 04:27 PM)MatthewH Wrote: [ -> ]I would just edit the existing login page and remove everything around the login code, except the logo.

Well, this is supposed to be more of a doorway instead of just a nice feature. On my forum, you can't see the forum without registering.

And just as an update for the lurkers, I've figured out how to force the user to login without the setting in mybb. As the setting makes it so you can't use a lot of the features of mybb without being logged in. However this modified code will check to see if the user is logged in just on the index page. It's a in the actual index.php file, so be sure you edit this with caution.


In your index.php file, find: 

// Load global language phrases
$lang->load('index');


after add:

if($mybb->user['uid'])
{

//Index Code here

then at the bottom of the page before: 

eval('$index = "'.$templates->get('index').'";');
output_page($index);
}

add: 

else
{
add_breadcrumb("Login", "login.php"); // (2)

eval("\$loginpage = \"".$templates->get("loginpage")."\";"); // (3)
output_page($loginpage); // (4)

}



And then you're done!