News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Adding my own navbar in default theme.

Started by Matthew K., September 11, 2009, 07:05:41 PM

Previous topic - Next topic

Matthew K.

Hey,

I am trying to add my own nav (CSS) into the SMF Default theme.

The problem I am having is I want to have a active tab and non-active tab like SMF and most menus. But I can't find the part of code that finds out whether it's active or not and then shows a different image.

What of SMF's code in the index.template.php do I edit to add in my menu's code?

I've obviously located where the menu is:
// 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('staff','tags','treasury','forum','search', 'bookmarks', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'banlist')))
$current_action = $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action = 'search';
if ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';



// EzPortal
if (isset($context['current_action2']))
$current_action = $context['current_action2'];

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

// Show the start of the tab section.
echo '
<table align="center" cellpadding="0" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">
<tr>
<td class="maintab_' , $first , '">&nbsp;</td>';

// 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>' : '';



// EzPortal Forum Button
global $ezpSettings;

if ($ezpSettings['ezp_portal_enable'] == 1)
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">' , $txt['ezp_forum_tab'] , '</a>
</td>' , $current_action == 'forum' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
// Show the [help] button.
echo ($current_action == 'help' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'help' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=help">' , $txt[119] , '</a>
</td>' , $current_action == 'help' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

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

// Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin'])
echo ($current_action == 'admin' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'admin' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=admin">' , $txt[2] , '</a>
</td>' , $current_action == 'admin' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Edit Profile... [profile]
if ($context['allow_edit_profile'])
echo ($current_action == 'profile' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'profile' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=profile">' , $txt[79] , '</a>
</td>' , $current_action == 'profile' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">

<a href="', $scripturl, '?action=pm">' , 'Inbox' , $context['user']['unread_messages'] > 0 ? '&nbsp;[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>';
                   echo ' </td>' , $current_action == 'pm' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

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

// The [calendar]!
if ($context['allow_calendar'])
echo ($current_action == 'calendar' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'calendar' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=calendar">' , $txt['calendar24'] , '</a>
</td>' , $current_action == 'calendar' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

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

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

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


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


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



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

// If the user is a guest, show [login] button.
if ($context['user']['is_guest'])
echo ($current_action == 'login' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'login' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=login">' , $txt[34] , '</a>
</td>' , $current_action == 'login' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=register">' , $txt[97] , '</a>
</td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
</td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// The end of tab section.
echo '
<td class="maintab_' , $last , '">&nbsp;</td>
</tr>
</table>';

}

// Generate a strip of buttons.
function template_button_strip($button_strip, $direction = 'top', $force_reset = false, $custom_td = '')
{
global $settings, $buttons, $context, $txt, $scripturl;

// Create the buttons...
foreach ($button_strip as $key => $value)
{
if (isset($value['test']) && empty($context[$value['test']]))
{
unset($button_strip[$key]);
continue;
}
elseif (!isset($buttons[$key]) || $force_reset)
$buttons[$key] = '<a href="' . $value['url'] . '" ' .( isset($value['custom']) ? $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>';

$button_strip[$key] = $buttons[$key];
}

if (empty($button_strip))
return '<td>&nbsp;</td>';

echo '
<td class="', $direction == 'top' ? 'main' : 'mirror', 'tab_' , $context['right_to_left'] ? 'last' : 'first' , '">&nbsp;</td>
<td class="', $direction == 'top' ? 'main' : 'mirror', 'tab_back">', implode(' &nbsp;|&nbsp; ', $button_strip) , '</td>
<td class="', $direction == 'top' ? 'main' : 'mirror', 'tab_' , $context['right_to_left'] ? 'first' : 'last' , '">&nbsp;</td>';
}


I am curious to which section of code renders the "Active" "Non-active" tab...

Thanks

SAFAD

Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Arantor

This is a code question.

The answer - several places, the first example:

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>' : '';


This will generate the different <td> items used in the menu. It's worth looking in the browser's View Source to see what it generates.
Holder of controversial views, all of which my own.


Matthew K.

Okay, looked through Browser Source.

What is the best way to go about adding my menu? Should I post my CSS/HTML code of menu I am going to be using?

Thanks...
Quote from: Arantor on September 11, 2009, 07:46:26 PM
This is a code question.

The answer - several places, the first example:

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>' : '';


This will generate the different <td> items used in the menu. It's worth looking in the browser's View Source to see what it generates.

Arantor

Are we talking about replacing the existing menu, or adding yours along side it?
Holder of controversial views, all of which my own.


Matthew K.

I am talking about completely replacing the SMF default menu system (from the main "top" menu on. But STARTING with the top).

I'll also start looking into custom theme and how they're coded =)

Thanks

Arantor

If you're just going to remove the default menu system, rip out the entire contents of template_menu and add your own - much quicker than messing about with editing the existing code.
Holder of controversial views, all of which my own.


Matthew K.

Quote from: Arantor on September 11, 2009, 08:44:05 PM
If you're just going to remove the default menu system, rip out the entire contents of template_menu and add your own - much quicker than messing about with editing the existing code.

If I completely rip out function_menu how do I get an active tab? (For instance, if you're on home, home is highlighted etc.)

I could go into each ?action= and add the nav, but for editing purposes that's not smart and would take a long time to update each time I required to change the nav for some reason.

Suggestions?

(I am going to try and just switch my CSS for SMF's CSS for now.)

Arantor

First up, adding it to the actions wouldn't help you, they have nothing to do with the menu at all.

I already posted the code for how it builds a single tab, and determines if it's active. It would help if I knew what you were trying to do to it.
Holder of controversial views, all of which my own.


Matthew K.

I have my custom navbar setup for the default theme, when I add "if ($context['allow_search'])" for instance, to the search link, the search button disappears (and yes, I do have permission) same thing with the Admin (
if ($context['allow_admin']))

How do I add the if context's for my nav so there is still some order to who see's what?

Also, I removed the template_menu as suggested and where the forum body should be I get the following error:
Fatal error: Call to undefined function template_menu() in /home/user/public_html/forum/Sources/Load.php(2125) : eval()'d code on line 526

I go to line 526 in Load.php and it's for User Arrays like:
'is_guest' => $ID_MEMBER == 0,
'is_admin' => in_array(1, $user_info['groups']),
'theme' => empty($user_settings['ID_THEME']) ? 0 : $user_settings['ID_THEME'],


etc..

Help appreciated =)

Matthew K.

My index.template.php code for the nav:

if ($context['allow_search'])
                        echo '
                <li><a href=#">Search</a></li>';
                       
                        if ($context['allow_admin'])
                        echo '
                        <li><a href="', $scripturl, '?action=admin">Admin</a>
                <ul>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                </ul>
     </li>';

Arantor

It would be helpful to keep this in a single thread, first of all - I'll merge this with your other one in a minute.

I didn't say anything about removing it. I said to remove its contents, which is why you're getting the error.
Holder of controversial views, all of which my own.


Matthew K.

Quote from: Arantor on September 12, 2009, 11:06:50 AM
It would be helpful to keep this in a single thread, first of all - I'll merge this with your other one in a minute.

I didn't say anything about removing it. I said to remove its contents, which is why you're getting the error.

Oh! Okay, so what do I enter back around the nav?

Arantor

First of all, restore the function fully before going any further so you have a working base.
Holder of controversial views, all of which my own.


Matthew K.

Quote from: Arantor on September 12, 2009, 11:13:17 AM
First of all, restore the function fully before going any further so you have a working base.

Right, that's what I meant :)

I replaced the old index.template.php from a backup so it's how it was before adding the nav.

Here is my nav code I wish to enter:
echo '
<div class="menu">
<ul>
<li><a href="#" >Home</a></li>
<li><a href="', $scripturl, '?action=help" id="current">Help</a>
<ul>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
       </ul>
                        </li>';
                       
                        <li><a href=#">Search</a></li>
                       
                        <li><a href="', $scripturl, '?action=admin">Admin</a>
                <ul>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                </ul>
     </li>
                        <li><a href="#">Profile</a></li>
                        <li><a href="#">Inbox</a></li>
                        <li><a href="#">Bookmarks</a></li>
                        <li><a href="#">Recent Topics</a></li>
                        <li><a href="#">Members</a></li>
                        <li><a href="#">Staff List</a></li>
                        <li><a href="#">Tags</a></li>
                        <li><a href="#">Donations</a></li>
                        <li><a href="#">Banlist</a></li>
                        <li><a href="#">Logout</a></li>
</ul>
</div>';


The code for the index.template.php default menu is:
// 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('staff','tags','treasury','forum','search', 'bookmarks', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'banlist')))
$current_action = $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action = 'search';
if ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';



// EzPortal
if (isset($context['current_action2']))
$current_action = $context['current_action2'];

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

// Show the start of the tab section.
echo '
<table align="center" cellpadding="0" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">
<tr>
<td class="maintab_' , $first , '">&nbsp;</td>';

// 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>' : '';



// EzPortal Forum Button
global $ezpSettings;

if ($ezpSettings['ezp_portal_enable'] == 1)
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">' , $txt['ezp_forum_tab'] , '</a>
</td>' , $current_action == 'forum' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
// Show the [help] button.
echo ($current_action == 'help' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'help' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=help">' , $txt[119] , '</a>
</td>' , $current_action == 'help' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

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

// Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin'])
echo ($current_action == 'admin' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'admin' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=admin">' , $txt[2] , '</a>
</td>' , $current_action == 'admin' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Edit Profile... [profile]
if ($context['allow_edit_profile'])
echo ($current_action == 'profile' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'profile' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=profile">' , $txt[79] , '</a>
</td>' , $current_action == 'profile' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">

<a href="', $scripturl, '?action=pm">' , 'Inbox' , $context['user']['unread_messages'] > 0 ? '&nbsp;[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>';
                   echo ' </td>' , $current_action == 'pm' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

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

// The [calendar]!
if ($context['allow_calendar'])
echo ($current_action == 'calendar' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'calendar' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=calendar">' , $txt['calendar24'] , '</a>
</td>' , $current_action == 'calendar' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

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

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

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


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


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



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

// If the user is a guest, show [login] button.
if ($context['user']['is_guest'])
echo ($current_action == 'login' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'login' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=login">' , $txt[34] , '</a>
</td>' , $current_action == 'login' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=register">' , $txt[97] , '</a>
</td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
</td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// The end of tab section.
echo '
<td class="maintab_' , $last , '">&nbsp;</td>
</tr>
</table>';

}


Thanks

Arantor

There is no support for dropdown menus in the default theme of SMF, meaning it's a lot more code to modify what you have to fit.

http://www.simplemachines.org/community/index.php?topic=253756.0 might have some relevant information though.
Holder of controversial views, all of which my own.


Matthew K.

Quote from: Arantor on September 12, 2009, 02:10:42 PM
There is no support for dropdown menus in the default theme of SMF, meaning it's a lot more code to modify what you have to fit.

http://www.simplemachines.org/community/index.php?topic=253756.0 might have some relevant information though.

Thanks, that's exactly what I needed!

Labradoodle-360

Advertisement: