User Menu in Sidebar

For support and discussion related to templates, themes, and imagesets in phpBB 3.0.
Get Involved
Locked
BriniaSona
Registered User
Posts: 393
Joined: Sun Sep 18, 2011 4:32 pm
Contact:

User Menu in Sidebar

Post by BriniaSona »

I have created a sidebar for metrolike style. I would like to add a user menu to it. When offline, the user menu shows a login box, and when online it displays unread posts and some links.

Board3Portal uses the same sidebar. Using this one would be good, but it doesnt seem to work right.

the code board3 uses for the sidebar
portal_user_menu.php
(5.82 KiB) Downloaded 9 times

rayminator
Registered User
Posts: 310
Joined: Wed Nov 15, 2006 1:37 pm
Name: raymond green
Contact:

Re: User Menu in Sidebar

Post by rayminator »

put this in your sidebar

Code: Select all

 <div class="panel">
                   <div class="inner"><span class="corners-top"><span></span></span>
                      <div style="padding:10px;">
                      <!-- IF not S_USER_LOGGED_IN -->
                       Please log in:<br />
<form method="POST" action="./ucp.php?mode=login">
<p>Username: <input type="text" name="username" size="40"><br />
Password: <input type="password" name="password" size="40"><br />
Remember Me?: <input type="checkbox" name="autologin"><br />
<input type="submit" value="Submit" name="login"></p>
<input type="hidden" name="redirect" value="index.php">
</form>
                         <br />
                         Not a member? <a title="Register" href="{U_REGISTER}">Register here!</a><br />
                         <a title="Forgot Password" href="{U_FORGOT_PASS}">I forgot my password!</a>
                      <!-- ELSE -->
                         <!-- IF AVATAR -->
                            {AVATAR}<br />
                         <!-- ENDIF -->
                            {RANK_TITLE}<br />
                            {RANK_IMG}<br />
                            <span style="color: '{USER_COLOR}'; font-weight: bold;">{USERNAME}</span><br />
                         <b>Welcome back!</b><br />
                         <ul><li><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a></li>
                         <li><a href="{U_PRIVATE_MESSAGES}">My Messages</a></li>
                         <li><a href="{U_NEW_POSTS}">{L_NEW_POSTS}</a></li>
                         <li><a href="{U_SELF_POSTS}">{L_SELF_POSTS}</a></li>
                         <li><a href="{U_VIEW_PROFILE}">{L_VIEW_PROFILE}</a></li></ul>
                      <!-- ENDIF -->
                      </div>
                   <span class="corners-bottom"><span></span></span></div>
                </div>
open index.php

fine

Code: Select all

// Output page
page_header($user->lang['INDEX']);
add before

Code: Select all

    // USER MENU BLOCK
    if($user->data['is_registered'])
    {
       // Get user info from the browser sessions...
       $user_id = $user->data['user_id'];
       $username = $user->data['username'];

       // grab user data from database based on info retrieved above
       $sql = 'SELECT *
          FROM ' . USERS_TABLE . '
          WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id");
       $result = $db->sql_query($sql);
       $member = $db->sql_fetchrow($result);

       // set variables retrieved from database query
       $username = $member['username'];
       $user_id = (int) $member['user_id'];
       $colour = $member['user_colour'];

       $sql = 'SELECT * FROM ' . RANKS_TABLE . ' WHERE rank_id = ' . $member['user_rank'];
       $result = $db->sql_query($sql);
       $rank = $db->sql_fetchrow($result);

       // Assign specific vars
       $template->assign_vars(array(
          'USERNAME_FULL'      => get_username_string('full', $user_id, $username, $colour),
          'USERNAME'             => get_username_string('username', $user_id, $username, $colour),
          'USER_COLOR'         => $member['user_colour'],
          'AVATAR'               => get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']),
          'RANK_TITLE'         => $rank['rank_title'],
       
          'L_VIEW_PROFILE'       => 'View Profile',
          'L_NEW_POSTS'          => 'New Posts',
          'L_SELF_POSTS'       => 'My Posts',

          'U_VIEW_PROFILE'       => $phpbb_root_path.'memberlist.php?mode=viewprofile&u='.$user_id,
          'U_PRIVATE_MESSAGES' => append_sid($phpbb_root_path.'ucp.' . $phpEx . '?i=pm&folder=inbox'),
          'U_LOGIN_LOGOUT'       => $phpbb_root_path.'ucp.'.$phpEx.'?mode=logout&subdir=1&sid='.$user->data['session_id'],
          'U_NEW_POSTS'          => append_sid($phpbb_root_path.'search.' . $phpEx . '?search_id=newposts'),
          'U_SELF_POSTS'       => append_sid($phpbb_root_path.'search.' . $phpEx . '?search_id=egosearch'),
       ));
    }
    // END USER MENU BLOCK
to add to other pages you would have to do this in most php file as well just make sure this line is in the php files include($phpbb_root_path . 'includes/functions_display.' . $phpEx); below this line include($phpbb_root_path . 'common.' . $phpEx); and the code above that goes to the index.php does not work in search pages

BriniaSona
Registered User
Posts: 393
Joined: Sun Sep 18, 2011 4:32 pm
Contact:

Re: User Menu in Sidebar

Post by BriniaSona »

It sorta worked, now the type fields stretch off the forum, and when logged in the linked appear as:

Welcome back!

Logout [ the General ]
My Messages
New posts
{ SELF_POSTS }
{ VIEW_PROFILE }

rayminator
Registered User
Posts: 310
Joined: Wed Nov 15, 2006 1:37 pm
Name: raymond green
Contact:

Re: User Menu in Sidebar

Post by rayminator »

change these two lines

Code: Select all

<li><a href="{U_SELF_POSTS}">{L_SELF_POSTS}</a></li>
<li><a href="{U_VIEW_PROFILE}">{L_VIEW_PROFILE}</a></li></ul>
into this

Code: Select all

<!-- IF not S_IS_BOT and S_USER_LOGGED_IN --><li><a rel="nofollow" href="{U_SEARCH_SELF_TOPICS}">{L_SEARCH_SELF_TOPICS}</a></li><!-- ENDIF -->
<a href="{U_PROFILE}" title="{L_PROFILE}" accesskey="e">{L_PROFILE}</a>
change this

Code: Select all

 Please log in:<br />
<form method="POST" action="./ucp.php?mode=login">
<p>Username: <input type="text" name="username" size="40"><br />
Password: <input type="password" name="password" size="40"><br />
Remember Me?: <input type="checkbox" name="autologin"><br />
<input type="submit" value="Submit" name="login"></p>
<input type="hidden" name="redirect" value="index.php">
</form>
                         <br />
                         Not a member? <a title="Register" href="{U_REGISTER}">Register here!</a><br />
                         <a title="Forgot Password" href="{U_FORGOT_PASS}">I forgot my password!</a>
to this

Code: Select all

<!-- IF not S_USER_LOGGED_IN and not S_IS_BOT -->
	<form method="post" action="{S_LOGIN_ACTION}" class="headerspace">
	<h3><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a><!-- IF S_REGISTER_ENABLED -->&nbsp; &bull; &nbsp;<a href="{U_REGISTER}">{L_REGISTER}</a><!-- ENDIF --></h3>
		<fieldset class="quick-login">
			<label for="username">{L_USERNAME}:</label>&nbsp;<input type="text" name="username" id="username" size="10" class="inputbox" title="{L_USERNAME}" />
			<label for="password">{L_PASSWORD}:</label>&nbsp;<input type="password" name="password" id="password" size="10" class="inputbox" title="{L_PASSWORD}" />
			<!-- IF S_AUTOLOGIN_ENABLED -->
				| <label for="autologin">{L_LOG_ME_IN} <input type="checkbox" name="autologin" id="autologin" /></label>
			<!-- ENDIF -->
			<input type="submit" name="login" value="{L_LOGIN}" class="button2" />
			{S_LOGIN_REDIRECT}
		</fieldset>
	</form>
open forms.css

find change the width

Code: Select all

fieldset.quick-login input.inputbox {
	width: 15%;
	vertical-align: middle;
	margin-right: 5px;
	background-color: #f3f3f3;
}

Locked

Return to “[3.0.x] Styles Support & Discussion”