Tab Selection States

smartpixels

Active member
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

  • selected-tabs-1.webp
    selected-tabs-1.webp
    35.5 KB · Views: 28
  • xenforo-tabs2.webp
    xenforo-tabs2.webp
    22.3 KB · Views: 21
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',
     );
   }
 
I would download some addons in the ressouces that have this behaviour and take a look, how the developers accomplished that.
 
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' 
        );
 
Back
Top Bottom