News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

How Do I Add A [Forum] and [Home] Button To My Navigation Menu?

Started by CrazyRed98, June 28, 2010, 09:59:49 PM

Previous topic - Next topic

CrazyRed98

Alright I'm trying to make it so my [home] button, when clicked redirects to the main page which is "http://hottechreviews.net/ [nofollow]", and for the [Forum] button I want to make it so when clicked it redirects to the forum page, which would be "http://hottechreviews.net/forum/ [nofollow]" or is it "http://hottechreviews.net/forum/index.php [nofollow]"

I think I was able to do it, but I'm not sure so If someone could check the code or check if I added it right.
Attachment included

The code bellow is just some of the code in the index.template.php file
// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

// Work out where we currently are.
$current_action = 'home';
if (in_array($context['current_action'], array('admin', 'ban', 'boardrecount', 'cleanperms', 'detailedversion', 'dumpdb', 'featuresettings', 'featuresettings2', 'findmember', 'maintain', 'manageattachments', 'manageboards', 'managecalendar', 'managesearch', 'membergroups', 'modlog', 'news', 'optimizetables', 'packageget', 'packages', 'permissions', 'pgdownload', 'postsettings', 'regcenter', 'repairboards', 'reports', 'serversettings', 'serversettings2', 'smileys', 'viewErrorLog', 'viewmembers')))
$current_action = 'admin';
if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'logout', 'help', 'pm')))
$current_action = $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action = 'search';
        if ($context['current_action'] == 'Forum')
           $current_action = 'Forum';

// Are we using right-to-left orientation?
if ($context['right_to_left'])
{
$first = 'last';
$last = 'first';
}
else
{
$first = 'first';
$last = 'last';
}

// Start of the tab section.
echo '
<ul>';


       // Show the [home] button.
          echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'home' ? 'active_back' : 'back' , '">
            <a href="', $scripturl, '">' , $txt[103] , '</a>
            </td>' , $current_action == 'home' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Show the [Forum] button.
        echo ($current_action=='Forum' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'Forum' ? 'active_back' : 'back' , '">
            <a href="', $scripturl, '?action=Forum">Forum</a>
            </td>' , $current_action == 'Forum' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

        // Show the [help] button.
echo ($current_action=='help' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'help' ? 'current' : '' , '"><a href="', $scripturl, '?action=help">' , $txt[119] , '</a></li>';

// How about the [search] button?
if ($context['allow_search'])
echo ($current_action=='search' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'search' ? 'current' : '' , '"><a href="', $scripturl, '?action=search">' , $txt[182] , '</a></li>';

// Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin'])
echo ($current_action=='admin' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'admin' ? 'current' : '' , '"><a href="', $scripturl, '?action=admin">' , $txt[2] , '</a></li>';

// Edit Profile... [profile]
if ($context['allow_edit_profile'])
echo ($current_action=='profile' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'profile' ? 'current' : '' , '"><a href="', $scripturl, '?action=profile">' , $txt[79] , '</a></li>';

// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action=='pm' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'pm' ? 'current' : '' , '"><a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a></li>';

// The [calendar]!
if ($context['allow_calendar'])
echo ($current_action=='calendar' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'calendar' ? 'current' : '' , '"><a href="', $scripturl, '?action=calendar">' , $txt['calendar24'] , '</a></li>';

// the [member] list button
if ($context['allow_memberlist'])
echo ($current_action=='mlist' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'mlist' ? 'current' : '' , '"><a href="', $scripturl, '?action=mlist">' , $txt[331] , '</a></li>';

echo '</ul>';

sAce

// Show the [home] button.
          echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'home' ? 'active_back' : 'back' , '">
            <a href="', $scripturl, '">' , $txt[103] , '</a>
            </td>' , $current_action == 'home' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
     
   // Show the [Forum] button.
        echo ($current_action=='Forum' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'Forum' ? 'active_back' : 'back' , '">
            <a href="', $scripturl, '?action=Forum">Forum</a>
            </td>' , $current_action == 'Forum' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

1. Should be the main site URL, not scripturl ( forum home page )
2. Only $scripturl is required, unless you are using a portal.

CrazyRed98

Quote from: S-Ace on June 28, 2010, 10:18:04 PM
// Show the [home] button.
          echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'home' ? 'active_back' : 'back' , '">
            <a href="', $scripturl, '">' , $txt[103] , '</a>
            </td>' , $current_action == 'home' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
     
   // Show the [Forum] button.
        echo ($current_action=='Forum' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'Forum' ? 'active_back' : 'back' , '">
            <a href="', $scripturl, '?action=Forum">Forum</a>
            </td>' , $current_action == 'Forum' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

1. Should be the main site URL, not scripturl ( forum home page )
2. Only $scripturl is required, unless you are using a portal.

Well I'm using "simple portal"
so this is what I replaced

// Show the [home] button.
          echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'home' ? 'active_back' : 'back' , '">
            <a href="http://hottechreviews.net/ [nofollow]">' , $txt[103] , '</a>
            </td>' , $current_action == 'home' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
     
   // Show the [Forum] button.
        echo ($current_action=='Forum' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'Forum' ? 'active_back' : 'back' , '">
            <a href="http://hottechreviews.net/forum/ [nofollow]">Forum</a>
            </td>' , $current_action == 'Forum' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

the bold things are the things i replaced with my website info. so is that all I needed to do?


Zagdul



Illori

please do not bump a topic within 24 hours we all volunteers and reply if and when we know the answer. also please do not bump old topics to add your issue to them, it is best to start a new topic. also this question has been answered many times you had searched you would have found the answer before you bumped the thread.

Advertisement: