• 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?

Mikey

Well-known member
#1
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.

PHP:
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.
 
#3
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

Well-known member
#4
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.
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.
Yes, they both use 'info'. Doh! My bad. Changed them and they work now! Thanks again guys