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

[Question] $tabs variable

Discussion in 'XenForo Questions and Support' started by SchmitzIT, Jan 16, 2011.

  1. SchmitzIT

    SchmitzIT Well-Known Member

    While looking for ways to add tabs to the navigation, I saw the following statement in the navigation template code:

    <xen:if is="{$tabs.help}">
    This implies that there is an array called $tabs, that contains the individual names of tabs to be added to the navigation bar. I've quickly gone through the options inthe admin CP, but did not find anywhere that this array is exposed. Is this purely due to this being considered as a future feature (having an admincp option to configure menus in would be freaking awesome!), or did I overlook something somewhere?

    In case it will be a future feature, can I already request the ability to add images to the tabs? I'm doing that manually now by adding an img tag containing the properties for the icons (align, width, heighth, borders and an alt tag - Apart from the alt-tag, I imagine the other options could be global for the navba- icons), but if this would be a standard feature, that'd definitly be a plus :)

    Cheers :)
  2. Jeremy P

    Jeremy P Well-Known Member

    Haven't done too much with it myself, but the ability to add additional tabs is exposed to addons via the navigation_tabs listener.
    EntropiaPlanets likes this.
  3. Mike

    Mike XenForo Developer Staff Member

    The array is used, but it's generated internally -- unless you use the navigation_tabs listener as suggested.
  4. SchmitzIT

    SchmitzIT Well-Known Member


    Thanks for the reply and the confirmation. Is there a guide anywhere on how to use the listener? I probably will end up doing a bit of coding, so I might as well start to learn the system properly :)

    Thanks in advance.

  5. Jeremy P

    Jeremy P Well-Known Member

  6. SchmitzIT

    SchmitzIT Well-Known Member

    Thanks. I did see that, but am not entirely sure what to do. I'll ask my questions in that thread, though :)
  7. Jeremy P

    Jeremy P Well-Known Member

    Well enable development mode on your test board for starters (wouldn't recommend it on production unless your site isn't live yet or something). Add
    $config['debug'] = true;
    to the end of your library/config.php file.

    Go to your ACP > Development > Create Addon
    Enter whateverYouWant for the addon id,
    Whatever You Want in the title,
    1.0.0 in Version String
    Leave Version ID at 0
    Hit save.

    Then create a folder in your library folder, such as library/WhateverYouWant/
    In that folder, create TabListener.php

    /** code by ragtek **/

    class WhateverYouWant_TabListener
         * add the "info" tab to the navbar
         * @param array $extraTabs
         * @param string $selectedTabId
    public static function addNavbarTab(array &$extraTabs$selectedTabId)
    $extraTabs['info'] = array(
    'title' => new XenForo_Phrase('ragtek_infopage_navbartitle'),//phrase with the title for the link
    'href'   => XenForo_Link::buildPublicLink('info'),
    'linksTemplate' => 'ragtek_infopage_navbar',      //if you want to have a "sub menu" you can create a template for this
    'position'  =>  'middle'  //since beta 5, you can choose the position, where the link should be placed      possible positions: [SIZE=3][FONT=Arial]middle end home[/FONT][/SIZE]
    Then in your ACP, go to Development > Code Event Listeners > Create..
    Select "navigation_tab" from the dropdown,
    Enter "WhateverYouWant_TabListener" in the class field,
    Enter "addNavbarTab" in the method field,
    Enter a description and select WhateverYouWant from the addon dropdown,
    and hit save.
    EntropiaPlanets likes this.
  8. Jeremy P

    Jeremy P Well-Known Member

    In the array, title is the text you want for the tab. In the above code it is phrased. It is good practice to create a new phrase for texts in your ACP, but you could just use a string.

    Href is the link, the above code uses a special method to generate a URL to a specific route, but again it can just be a string.

    linksTemplate is the template (created in the ACP) for the dropdown links for the tab..

Share This Page