1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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

Discussion in 'Tips and Guides [Archive]' started by Jake Bunce, Nov 8, 2010.

  1. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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:

    						<li><a href="{xen:link 'find-new/threads'}">{xen:phrase whats_new}</a></li>
    		<!-- 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:

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

    Allan Well-Known Member

    Thank you Jake :)

    One question, the new tab stay in front of others when one click it ?
  3. ragtek

    ragtek Guest

    zincmix, Garamond and ajnos like this.
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.
  5. ragtek

    ragtek Guest

    That's why it would be great, to have an "Menu Manager" where we could create & edit the menu entries
    Carlos, Chimpie, Garamond and 7 others like this.
  6. JVCode

    JVCode Well-Known Member

    Put it up as a request, a modder might take this on, though it would be best suited as a core feature.
  7. ragtek

    ragtek Guest

    AFAIK there's already a feature request
  8. Ray

    Ray Active Member

  9. anotheralias

    anotheralias Well-Known Member

    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")
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That's fine. Here is the code for your What's New tab:

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

    anotheralias Well-Known Member

    Ah THANK you! Sparing me from my usual trial-and-error method. :)
    tural08 likes this.
  12. Brogan

    Brogan XenForo Moderator Staff Member

    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:
    <xen:if is="{$visitor.user_id}">
    <li class="navTab PopupClosed"><a href="{xen:link account/upgrades}" class="navLink">{xen:phrase account_upgrades}</a></li>
    Glockie, AC_Khanh01, Inkman and 5 others like this.
  13. Ranger375

    Ranger375 Well-Known Member

    Is there a way to change the color of the text in the newly added tab?
  14. ddmmh

    ddmmh Well-Known Member

  15. bogus

    bogus Guest

    And how can i add a tab with pulldown?
  16. Kane Hart

    Kane Hart Active Member

    just used this and works perfectly. Though a plugin for this be nice in the future.
  17. AndreaMarucci

    AndreaMarucci Well-Known Member

    Fantastic!!! XenForo shoud have a menu manager in the next version...
    ddmmh likes this.
  18. AndreaMarucci

    AndreaMarucci Well-Known Member

    Stupid, maybe, question. Is it possible to add the menu after the last one on the right? After the Help menu I mean?​
  19. Brogan

    Brogan XenForo Moderator Staff Member

    Which menu?

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

    AndreaMarucci Well-Known Member


                    <!-- 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>
    mtha likes this.

Share This Page