TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 28, 2024, 08:23:08 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,104
  • Total Topics: 21,212
  • Online today: 152
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 169
  • Total: 170
  • tino

vertical menu!

Started by gdblaster, October 03, 2006, 07:44:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gdblaster

i wanted a vertical menu for my entire portal in the left part and i made it in html (code writen in a tiny portal block). but that menu contains the main parts of the portal! now i want to make an user menu at the top of the page in the user information box! to contain 'profile' 'pms' 'admin' (only for administrators) and 'login', 'logout', 'register' for guests! i tried many times but it didn't work. please help me cause i want to make a good website!

thank you in advance! and some screenshots to see what i'm talking about!

JPDeni

If you want a dynamic menu -- one that changes based on who is looking at it -- you'll need to use a php block.

You can use the code below:
global $context, $scripturl, $txt;

if($context['user']['is_logged'])
{
  echo '<a href="'.$scripturl.'?action=profile;u='.$context['user']['id'].'">Profile</a>'; // Profile
  if ($context['allow_pm']){
    echo '<br /><a href="', $scripturl, '?action=pm">' .$txt['tp-pm'].' ', $context['user']['messages'], '</a>'; //Messages
      if($context['user']['unread_messages']>0)
        echo '<br /><a style="font-weight: bold; " href="', $scripturl, '?action=pm">' .$txt['tp-pm2'].' ',$context['user']['unread_messages'] , '</a>'; // New messages
  }
  if ($context['allow_admin'])
    echo '<br /><a href="', $scripturl, '?action=admin">' , $txt[2] , '</a>'; // Admin
  echo '<br /><a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>'; // Log out

}
else
{
  echo '<a href="'.$scripturl.'?action=login">' , $txt[34] , '</a>'; // Log in
  echo '<br /><a href="', $scripturl, '?action=register">' , $txt[97] , '</a>'; // Register
}


This doesn't have any formatting or icons or anything like that in it, but it does have the links, based on whether the user is logged in or not and whether the user is an admin.

gdblaster

thank you for the code ... no problem ... i will add the images ... i will try it and i will tell if it works or not

gdblaster

#3
i added your code and it was a vertical menu (only the links). i added the images and i added align="right" property in img tag. and look what problem i have now! every time i added the code for the menu it was like in the picture

here is the code:

// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{

//Testing Menu
if ($context['allow_edit_profile'])
echo '<a href="'.$scripturl.'?action=profile;u='.$context['user']['id'].'">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/menu/profile.gif" alt="Edit Profile""' . $txt[79] . '" style="margin: 2px 0;" align="right" border="0" />' : $txt[467]), '</a>'; // Profile

  if ($context['allow_pm'])
  echo '<br /><a href="', $scripturl, '?action=pm">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/im_new.gif" alt="View Messages""' . $txt[79] . '" style="margin: 2px 0;" align="right" border="0" />' : $txt[467]), '</a>'; //Messages
 
  if ($context['allow_admin'])
    echo '<br /><a href="', $scripturl, '?action=admin">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/menu/administrator.gif" alt="Administration Panel""' . $txt[79] . '" style="margin: 2px 0;" align="right" border="0" />' : $txt[2]), '</a>'; // Admin

  echo '<br /><a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/menu/logout.gif" alt="Log Out""' . $txt[108] . '" style="margin: 2px 0;" align="right" border="0" />' : $txt[108]), '</a>'; // Log out

// Welcomes Logged User!
echo '
', $txt['hello_member'], ' <b>', $context['user']['name'], '</b>';

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
echo ', ', $txt[152], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt[153] : $txt[471], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'];
echo '.<br />';

// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '
<b>', $txt[616], '</b><br />';

// Are there any members waiting for approval?
if (!empty($context['unapproved_members']))
echo '
', $context['unapproved_members'] == 1 ? $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="', $scripturl, '?action=viewmembers;sa=browse;type=approve">', $context['unapproved_members'] == 1 ? $txt['approve_member'] : $context['unapproved_members'] . ' ' . $txt['approve_members'], '</a> ', $txt['approve_members_waiting'], '<br />';

// Show the total time logged in?
if (!empty($context['user']['total_time_logged_in']))
{
echo '
', $txt['totalTimeLogged1'];

// If days is just zero, don't bother to show it.
if ($context['user']['total_time_logged_in']['days'] > 0)
echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];

// Same with hours - only show it if it's above zero.
if ($context['user']['total_time_logged_in']['hours'] > 0)
echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];

// But, let's always show minutes - Time wasted here: 0 minutes ;).
echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '<br />';
}
echo '
<a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a><br />
<a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a><br />', $context['current_time'];
}

JPDeni

I added your code and it was a vertical menu (only the links)
Which is what you asked for.

I'm sorry. I thought you wanted a vertical menu in a block that had the user controls, which would be like the vertical menu you already made. Now that I read what you wrote again, I see that you said, "in the user information box."

I'm not that great with css, but instead of
style="margin: 2px 0;" align="right" border="0" />
you might try
style="margin: 2px 0; float:right; border-style:none:" />

gdblaster

i made it ... i created another column of the table (cause until now it had 2 columns - 1 for avatar and another for information) and i used your code and it's perfect now! thank you! maybe i will write here the code but later :D