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

Code Event Listeners cancelling each other out?

Discussion in 'XenForo Development Discussions' started by Mikey, May 26, 2011.

  1. Mikey

    Mikey Well-Known Member

    I have two code event listeners for two different add ons, one seems to cancel the other out?

    Both listen to "navigation_tabs" and look pretty much the same.

    public static function addNavbarTab(array & $extraTabs$selectedTabId)
    $options XenForo_Application::get('options');
       if (
    $options->AddOnTabEnabled) {
    $extraTabs['info'] = array(
    'title' => new XenForo_Phrase('AddOn_NavTab_TabName'),
    'linksTemplate' => 'AddOn_NavTab_TabMenu',
    'href' => XenForo_Link::buildPublicLink('addon'),
    'position' => $options->AddOnNavTabPosition
    At first I thought it was because both have the same function name (addNavbarTab) so I changed them to addAddOnNavbarTab, but still no dice.

    Am I doing something wrong? Why would one cancel the other out?

    Sorry for the influx of questions, btw.
  2. Kier

    Kier XenForo Developer Staff Member

    Do they both set $extraTabs['info'] ?

    The only thing I can think of is that you are using 'info' as the key in both add-ons, when they key must be unique per tab.
    Vodkaholic and Mikey like this.
  3. Martin Aronsen

    Martin Aronsen Active Member

    The only reason I can see this happening if is both are using 'info' as the key in the $extraTabs array. If that's the case, the last one will overwrite the first.
    Mikey likes this.
  4. Mikey

    Mikey Well-Known Member

    Yes, they both use 'info'. Doh! My bad. Changed them and they work now! Thanks again guys
    Kier likes this.
  5. Wuebit

    Wuebit Well-Known Member

    Ha had the same problem :p thanks man

Share This Page