• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

How To Add A New Tab In The Navbar

Jake Bunce

XenForo moderator
Staff member
#1
This will create a simple tab link in the navbar. No popup or submenu. Here is a picture of what it looks like (in this example the user wanted a link for Account Upgrades):

Screen shot 2010-11-08 at 11.41.25 AM.png

Edit this template:

Admin CP -> Appearance -> Templates -> navigation

Add the red code, and change the blue parts appropriately:

Code:
						<li><a href="{xen:link 'find-new/threads'}">{xen:phrase whats_new}</a></li>
					</ul>
				</div>
			</li>
		</xen:if>


		<!-- mytab -->
		<li class="navTab PopupClosed"><a href="LINK" class="navLink">TAB LABEL</a></li>


		<!-- extra tabs -->
		<xen:if is="{$extraTabs}">
		<xen:foreach loop="$extraTabs" key="$extraTabId" value="$extraTab">
			<xen:if is="{$extraTab.linksTemplate}">
While you can 'hard code' the LINK and TAB LABEL, ideally you should use xen:link and xen:phrase. For example, here is the proper code for the Account Upgrades picture above:

Code:
		<!-- mytab -->
		<li class="navTab PopupClosed"><a href="{xen:link account/upgrades}" class="navLink">{xen:phrase account_upgrades}</a></li>
 

Jake Bunce

XenForo moderator
Staff member
#4
One question, the new tab stay in front of others when one click it ?
This tab doesn't turn active when you visit its page. That can be done with a proper code event listener like what ragtek posted. That means you need to delve into the code.
 

anotheralias

Well-known member
#9
This tab doesn't turn active when you visit its page. That can be done with a proper code event listener like what ragtek posted. That means you need to delve into the code.
The fact that it doesn't turn active would work out perfectly for me if it's possible to put the "what's new" link in that tab. Is there any reason I shouldn't?

(Why - because it saves a click. "Inbox/Forum/what's new" vs. "inbox/what's new")
 

Jake Bunce

XenForo moderator
Staff member
#10
The fact that it doesn't turn active would work out perfectly for me if it's possible to put the "what's new" link in that tab. Is there any reason I shouldn't?

(Why - because it saves a click. "Inbox/Forum/what's new" vs. "inbox/what's new")
That's fine. Here is the code for your What's New tab:

Code:
		<!-- mytab -->
		<li class="navTab PopupClosed"><a href="{xen:link 'find-new/threads'}" class="navLink">{xen:phrase whats_new}</a></li>
 

Brogan

XenForo moderator
Staff member
#12
Nice guide Jake.

One small change I would make though would be to add a guest conditional, so the tab doesn't show up if not logged in.
That can be achieved with the following:
HTML:
<xen:if is="{$visitor.user_id}">
<li class="navTab PopupClosed"><a href="{xen:link account/upgrades}" class="navLink">{xen:phrase account_upgrades}</a></li>
</xen:if>
 

Brogan

XenForo moderator
Staff member
#19
Which menu?

Just change the order of the tabs in the template for how you want them to appear on the nav bar.
 

AndreaMarucci

Well-known member
#20
Done

Code:
                <!-- mytab -->
        <li class="navTab PopupClosed"><a href="LINK" class="navLink">MENU</a></li>

        <!-- no selection -->
        <xen:if is="!{$selectedTab}">
            <li class="navTab selected"><div class="tabLinks"></div></li>
        </xen:if>