1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Add Tab through Addon

Discussion in 'XenForo Development Discussions' started by Grinch, Jun 24, 2014.

  1. Grinch

    Grinch Member

    Hey guys, I'm pretty new to web development so please bear with me a bit.

    I'm working on an addon and I cannot for the life of me figure out how to go about adding a tab with it. Most search results for xenforo.com lead me to people saying 'use Nodes as Tabs' which isn't actually a solution to my need.

    If someone could help me out a bit here I would be most grateful. :)
  2. Syndol

    Syndol Guest

    Hi @Grinch
    If you take a look at Dependencies/Public.php, function _getNavigationContainerParams(), you will see a XenForo_CodeEvent called navigation_tabs
    You call this event by creating a Code Event Listener for navigation_tabs which calls your PHP file that includes a function such as addMyTab(array &$extraTabs, $selectedTabId)
    This function adds your tab to the $extraTabs array as follows:
    $extraTabs['MyTab'] = array(
    'title' => new XenForo_Phrase('mytab_name'), // title of tab
    'href' => XenForo_Link::buildPublicLink('mytab_location'), // where to link your tab to when tab title is clicked
    'position' => mytab_location_within_the_tabs//  location of tab such as 'home', 'middle', or 'end'
    'linksTemplate' => 'mytab_template' // name of your template that displays what it is you want the tab to show
    I hope this helps.
    oman likes this.
  3. Grinch

    Grinch Member

    What would I need to do to handle tab selection as well?
  4. AndyB

    AndyB Well-Known Member

Share This Page