2012-02-17, 08:33 PM
This has been asked a few times now so I thought I'd do a quick tutorial.
I'm not going to worry about styling the menu in this tutorial, this is purely to show you how to set the current/active state on your menu. It's up to you to make it look pretty. The following is based on the default MyBB 1.6 theme and default MyBB pages but it should be easy for anyone to use the same theory on a custom theme or custom pages.
First we need to add a few new items to the menu.
ACP >> Templates & Style >> Templates >> yourtheme >> Header Templates >> header
Find:
Add after:
Now we need to add a unique ID to each list item, for each list item make the following change:
Find:
Replace with:
You should now have something like this:
We need to add some CSS to match the list item ID's with the body ID's we're going to add in a minute . I've just used the hover state styling from the default theme. If you're using this tutorial on anything but the default theme I recommend you copy and paste the CSS from the .menu ul a:hover, .menu ul a:active class and use that (or something similar) instead.
ACP >> Templates & Style >> Themes >> yourtheme >> global.css
Add:
Now we need to assign unique ID's to the body tags in our templates, I'm not going to go through every single one because there are a lot you could possibly want to add. But here's the general idea...
ACP >> Templates & Style >> Templates >> yourtheme >> Portal Templates >> portal
Find:
Replace with:
You should now see the current/active state on the menu when you're on the portal!
ACP >> Templates & Style >> Templates >> yourtheme >> Index Page Templates >> index
Find:
Replace with:
Hopefully by now you're starting to get the idea...?
ACP >> Templates & Style >> Templates >> yourtheme >> Search Templates >> search
Find:
Replace with:
ACP >> Templates & Style >> Templates >> yourtheme >> Member List Templates >> memberlist
Find:
Replace with:
If you still haven't got it, give up! Otherwise, carry on making the same changes in other templates until you have it all set up the way you like.
That's it!
I'm not going to worry about styling the menu in this tutorial, this is purely to show you how to set the current/active state on your menu. It's up to you to make it look pretty. The following is based on the default MyBB 1.6 theme and default MyBB pages but it should be easy for anyone to use the same theory on a custom theme or custom pages.
First we need to add a few new items to the menu.
ACP >> Templates & Style >> Templates >> yourtheme >> Header Templates >> header
Find:
<div class="menu">
<ul>
Add after:
<li><a href="{$mybb->settings['bburl']}/portal.php"><img src="{$theme['imgdir']}/usercp/home.gif" alt="" title="" />{$lang->toplinks_portal}</a></li>
<li><a href="{$mybb->settings['bburl']}/index.php"><img src="{$theme['imgdir']}/usercp/fsubscriptions.gif" alt="" title="" />Forums</a></li>
Now we need to add a unique ID to each list item, for each list item make the following change:
Find:
<li>
Replace with:
<li id="nav-portal">
You should now have something like this:
<div class="menu">
<ul>
<li id="nav-portal"><a href="{$mybb->settings['bburl']}/portal.php"><img src="{$theme['imgdir']}/usercp/home.gif" alt="" title="" />{$lang->toplinks_portal}</a></li>
<li id="nav-forums"><a href="{$mybb->settings['bburl']}/index.php"><img src="{$theme['imgdir']}/usercp/fsubscriptions.gif" alt="" title="" />Forums</a></li>
<li id="nav-search"><a href="{$mybb->settings['bburl']}/search.php"><img src="{$theme['imgdir']}/toplinks/search.gif" alt="" title="" />{$lang->toplinks_search}</a></li>
<li id="nav-member"><a href="{$mybb->settings['bburl']}/memberlist.php"><img src="{$theme['imgdir']}/toplinks/memberlist.gif" alt="" title="" />{$lang->toplinks_memberlist}</a></li>
<li id="nav-calendar"><a href="{$mybb->settings['bburl']}/calendar.php"><img src="{$theme['imgdir']}/toplinks/calendar.gif" alt="" title="" />{$lang->toplinks_calendar}</a></li>
<li id="nav-help"><a href="{$mybb->settings['bburl']}/misc.php?action=help"><img src="{$theme['imgdir']}/toplinks/help.gif" alt="" title="" />{$lang->toplinks_help}</a></li>
</ul>
</div>
We need to add some CSS to match the list item ID's with the body ID's we're going to add in a minute . I've just used the hover state styling from the default theme. If you're using this tutorial on anything but the default theme I recommend you copy and paste the CSS from the .menu ul a:hover, .menu ul a:active class and use that (or something similar) instead.
ACP >> Templates & Style >> Themes >> yourtheme >> global.css
Add:
#portal #nav-portal a,
#forums #nav-forums a,
#search #nav-search a,
#member #nav-member a,
#calendar #nav-calendar a,
#help #nav-help a {
color: #4874a3; /* replace with your styling */
text-decoration: none; /* replace with your styling */
}
Now we need to assign unique ID's to the body tags in our templates, I'm not going to go through every single one because there are a lot you could possibly want to add. But here's the general idea...
ACP >> Templates & Style >> Templates >> yourtheme >> Portal Templates >> portal
Find:
<body>
Replace with:
<body id="portal">
You should now see the current/active state on the menu when you're on the portal!
ACP >> Templates & Style >> Templates >> yourtheme >> Index Page Templates >> index
Find:
<body>
Replace with:
<body id="forums">
Hopefully by now you're starting to get the idea...?
ACP >> Templates & Style >> Templates >> yourtheme >> Search Templates >> search
Find:
<body>
Replace with:
<body id="search">
ACP >> Templates & Style >> Templates >> yourtheme >> Member List Templates >> memberlist
Find:
<body>
Replace with:
<body id="member">
If you still haven't got it, give up! Otherwise, carry on making the same changes in other templates until you have it all set up the way you like.
That's it!