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

Tab Selection States

#1
I was trying to bring help menu into the main navigation bar and developed a mini addon but I am unable to get XF change the state of tabs to selected

The tab and submenus are working fine but not the selection.

I thought help menus have route prefix
 

Attachments

Marcus

Well-known member
#2
Set a listener to navtabs, this is an example code for your class
PHP:
public static function listener(array &$extraTabs, $selectedTabId)
   {  
     $extraTabs['help'] = array(
         'title' => 'Help',
         'href' => XenForo_Link::buildPublicLink('full:help'),
         'selected' =>  ($selectedTabId == 'help'),
         'position' => 'middle',
         'linksTemplate' => 'my_addon_help_navtab',
     );
   }
 

Marcus

Well-known member
#3
I would download some addons in the ressouces that have this behaviour and take a look, how the developers accomplished that.
 
#4
I would download some addons in the ressouces that have this behaviour and take a look, how the developers accomplished that.
Thank you.
The addon developer would create their own route controller for pages they create.
For such a small addon I don't think I need to create one there must be a simple way.

Anyway
'selected' => ($selectedTabId == 'help'), is not needed. Xenforo should detect it on its own.
This is the listener I am using now

PHP:
    public static function navigationTabs(array &$extraTabs, $selectedTabId)
    {    
            $extraTabs['help'] = array(
            'title' => new XenForo_Phrase('smart_nav_help'),
            'href'  => XenForo_Link::buildPublicLink('full:help'),
           'linksTemplate' => 'smart_navigation_tab_help',    
            'position'  =>  'end' 
        );