News:

Wondering if this will always be free?  See why free is better.

Main Menu

trying to add buttons to the menu

Started by 1MileCrash, June 09, 2005, 02:55:48 PM

Previous topic - Next topic

1MileCrash

before i destroy my forums, i want to know if i did this correctly. I want to add a gallery button to the nav. bar. Already uploaded it and all. Tell me if the code is right. What i added is in red.

Quote// Show the menu up top.  Something like [home] [help] [profile] [logout]...
function template_menu()
{
   global $context, $settings, $options, $scripturl, $txt;

   // Show the [home] and [help] buttons.
   echo '
            <a href="', $scripturl, '">',

($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' .

$context['user']['language'] . '/home.gif" alt="' . $txt[103] . '" style="margin: 2px 0;"

border="0" />' : $txt[103]), '</a>', $context['menu_separator'], '
            <a href="', $scripturl, '?action=help" target="_blank">',

($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' .

$context['user']['language'] . '/help.gif" alt="' . $txt[119] . '" style="margin: 2px 0;"

border="0" />' : $txt[119]), '</a>', $context['menu_separator'];

   // How about the [search] button?
   if ($context['allow_search'])
      echo '
            <a href="', $scripturl, '?action=search">',

($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' .

$context['user']['language'] . '/search.gif" alt="' . $txt[182] . '" style="margin: 2px 0;"

border="0" />' : $txt[182]), '</a>', $context['menu_separator'];

   // Is the user allowed to administrate at all? ([admin])
   if ($context['allow_admin'])
      echo '
            <a href="', $scripturl, '?action=admin">',

($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' .

$context['user']['language'] . '/admin.gif" alt="' . $txt[2] . '" style="margin: 2px 0;"

border="0" />' : $txt[2]), '</a>', $context['menu_separator'];

   // Edit Profile... [profile]
   if ($context['allow_edit_profile'])
      echo '
            <a href="', $scripturl, '?action=profile">',

($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' .

$context['user']['language'] . '/profile.gif" alt="' . $txt[79] . '" style="margin: 2px 0;"

border="0" />' : $txt[467]), '</a>', $context['menu_separator'];

   // The [calendar]!
   if ($context['allow_calendar'])
      echo '
            <a href="', $scripturl, '?action=calendar">',

($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' .

$context['user']['language'] . '/calendar.gif" alt="' . $txt['calendar24'] . '"

style="margin: 2px 0;" border="0" />' : $txt['calendar24']), '</a>',

$context['menu_separator'];


   // Integrated Chat Mod Icon
   if (!$context['user']['is_guest'])
      echo '
            <a href="', $scripturl, '?action=chat" target="_blank">',

($settings['use_image_buttons'] ? ' <img src="' . $settings['images_url'] . '/' .

$context['user']['language'] . '/chat.gif" alt="' . $txt['chatAlt'] . '" target="_blank"

style="margin: 2px 0;" border="0" />' : $txt['chatAlt']), '</a>',

$context['menu_separator'];

echo '
<a href="PBCommunity.Net">', ($settings['use_image_buttons'] ? '<img src="gallery.gif"

alt="gallery" style="margin: 2px 0;" border="0" />' : gallery), '</a>';




   // If the user is a guest, show [login] and [register] buttons.
   if ($context['user']['is_guest'])
   {
      echo '
            <a href="', $scripturl, '?action=login">',

($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' .

$context['user']['language'] . '/login.gif" alt="' . $txt[34] . '" style="margin: 2px 0;"

border="0" />' : $txt[34]), '</a>', $context['menu_separator'], '
            <a href="', $scripturl, '?action=register">',

($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' .

$context['user']['language'] . '/register.gif" alt="' . $txt[97] . '" style="margin: 2px 0;"

border="0" />' : $txt[97]), '</a>';
   }
   // Otherwise, they might want to [logout]...
   else
      echo '
            <a href="', $scripturl, '?action=logout;sesc=',

$context['session_id'], '">', ($settings['use_image_buttons'] ? '<img src="' .

$settings['images_url'] . '/' . $context['user']['language'] . '/logout.gif" alt="' .

$txt[108] . '" style="margin: 2px 0;" border="0" />' : $txt[108]), '</a>';
}

?>
The only thing php can't do is tell you how much milk is left in the fridge.



1MileCrash

w00t! it worked. I just had to change the url to the image and the url i wanted it to go to. I love smf.
The only thing php can't do is tell you how much milk is left in the fridge.



Foreverpurple

Thank you for posting this and the full code showing where to place it! I've been fighting with this for days!

1MileCrash

just start with echo' and end with '; after a previous '; and you'll be fine.
The only thing php can't do is tell you how much milk is left in the fridge.



Advertisement: