Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

Reply
 
Thread Tools
Custom Login Page
Trasion
Join Date: Sep 2009
Posts: 178

 

New York
Show Printable Version Email this Page Subscription
Trasion Trasion is offline 09-05-2009, 10:00 PM

I personally hate seeing that ugly login box at the top of the screen in the navbar template. I came up with this quick and easy fix, have a separate page for it.

If you'd like a custom login page, and simply have to link to it in your navbar, then follow the quick steps below.

Step 1) Create a new .php file called clogin.php (it must be named this, do not change the name), and upload it to your forum root directory.

Step 2) Put the below code in your new clogin.php file:

Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'clogin'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(
    
);

// pre-cache templates used by all actions
$globaltemplates = array(
    'clogin',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits = array();
$navbits[$parent] = 'Login';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('clogin') . '");');

?>
Step 3) Open up all styles you're using (one at a time) in the administration control panel, and create a new template called "clogin" (without the quotation marks) - once again, it must be named this, do not change the name.

Step 4) Insert the following code into your "clogin" (without the quotation marks):

Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
    <td class="tcat">Login</td>
</tr>
<tr>
    <td class="alt1">

<if condition="$show['member']">
<meta HTTP-EQUIV="REFRESH" content="0; url=index.php">
</if>

Welcome to SITENAME, Guest.<br /><br />

You appear to either not have an account, or not be logged in. If you have an account, please login using this page right below this text. If you do not have an account already, please visit the <i>register</i> page by clicking <a href="register.php">here</a>.<br /><br />

By being a member of SITENAME, you will have rights to create threads, and posts, release and download software, and do so much more. Please login below.<br /><br />

		<!-- login form -->
		<form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])">
		<script type="text/javascript" src="clientscript/vbulletin_md5.js?v=$vboptions[simpleversion]"></script>
		<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
		<tr>
			<td class="smallfont" style="white-space: nowrap;"><label for="navbar_username">$vbphrase[username]</label></td>
			<td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="$vbphrase[username]" onfocus="if (this.value == '$vbphrase[username]') this.value = '';" /></td>
			<td class="smallfont" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />$vbphrase[remember_me]</label></td>
		</tr>
		<tr>
			<td class="smallfont"><label for="navbar_password">$vbphrase[password]</label></td>
			<td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" tabindex="102" /></td>
			<td><input type="submit" class="button" value="$vbphrase[log_in]" tabindex="104" title="$vbphrase[enter_username_to_login_or_register]" accesskey="s" /></td>
		</tr>
		</table>
		<input type="hidden" name="s" value="$session[sessionhash]" />
		<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
		<input type="hidden" name="do" value="login" />
		<input type="hidden" name="vb_login_md5password" />
		<input type="hidden" name="vb_login_md5password_utf" />
		</form>
		<!-- / login form -->

</td>
</tr>
</table>

$footer
</body>
</html>
This will make it so that if any registered member tries to access this page, it will redirect them to your forum index, and if they're a guest, they get to see the login script, and can login.

You must change all of the "SITENAME" text in your new template to your actual site name.

Please post here if you need assistance, please.

Credits to Gary King! (https://vborg.vbsupport.ru/showthread.php?t=62164)
Reply With Quote
  #2  
Old 10-07-2009, 05:58 PM
inder123 inder123 is offline
 
Join Date: Jan 2008
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

installed but not works
Reply With Quote
  #3  
Old 10-07-2009, 08:25 PM
Front Range 4x4 Front Range 4x4 is offline
 
Join Date: Jan 2009
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It works but Trasion left out a step. I think what his intent was to add a Login link to the navbar linked to your page: yoursite.com/forums/clogin.php

Nice work Trasion!

--------------- Added [DATE]1254951467[/DATE] at [TIME]1254951467[/TIME] ---------------

It looks like this works when added to the navbar:

$template_hook[navbar_buttons_right]
<td class="vbmenu_control">
<a href="clogin.php?">Log In</a></td>

--------------- Added [DATE]1254952892[/DATE] at [TIME]1254952892[/TIME] ---------------

Then you need to delete the old login form from the navbar template.
Reply With Quote
  #4  
Old 10-10-2009, 12:41 PM
Trasion Trasion is offline
 
Join Date: Sep 2009
Location: New York
Posts: 178
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, you must add that too. Sorry.

After you go to that page, it should work!
Reply With Quote
  #5  
Old 10-12-2009, 01:18 AM
Front Range 4x4 Front Range 4x4 is offline
 
Join Date: Jan 2009
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It should and it does. After testing I have added it to my board. This allows for a larger site logo without pushing things around for users with small screens.:up:
Attached Images
File Type: jpg screenshot_01.jpg (37.4 KB, 0 views)
Reply With Quote
  #6  
Old 10-18-2009, 12:43 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You might want to add a condition to remove the Log In button if the user is logged in and replace it with Log Out.
Reply With Quote
  #7  
Old 10-18-2009, 03:30 PM
Front Range 4x4 Front Range 4x4 is offline
 
Join Date: Jan 2009
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Meh. My users know which one to click.
Reply With Quote
  #8  
Old 10-18-2009, 05:39 PM
Trasion Trasion is offline
 
Join Date: Sep 2009
Location: New York
Posts: 178
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
<td class="vbmenu_control">
<if condition="$show['guest']">
<a href="clogin.php">Login</a>
<else />
<a href="login.php?$session[sessionurl]do=logout&amp;logouthash=$bbuserinfo[logouthash]">$vbphrase[log_out]</a>
</if>
</td>
Reply With Quote
  #9  
Old 11-05-2009, 04:31 PM
dacho's Avatar
dacho dacho is offline
 
Join Date: Dec 2004
Location: Tell-Aviv
Posts: 224
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I do that
but if i want to stay in the some page "clogin.php" without to go after login (or if I'm conected) to index.php
just a pape for login and say HELLO
Reply With Quote
  #10  
Old 11-11-2009, 05:38 PM
abstroose abstroose is offline
 
Join Date: Nov 2008
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks a lot! I've spent an hour hunting for a mod so I can put a login link on my blog, but this works perfectly.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:05 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04510 seconds
  • Memory Usage 2,310KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete