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

Tab Selection States

Discussion in 'XenForo Development Discussions' started by smartpixels, Aug 23, 2013.

  1. smartpixels

    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

    Attached Files:

  2. Marcus

    Marcus Well-Known Member

    Set a listener to navtabs, this is an example code for your class
    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',
  3. Marcus

    Marcus Well-Known Member

    I would download some addons in the ressouces that have this behaviour and take a look, how the developers accomplished that.
  4. smartpixels

    smartpixels Active Member

    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.

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

        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' 
  5. Marcus

    Marcus Well-Known Member

    Does it work now on your forum with displaying the selected tab as it should?
  6. smartpixels

    smartpixels Active Member

    The menu works but the selected tab is not
  7. Marcus

    Marcus Well-Known Member

    Did you try
    'selected' => ($selectedTabId == 'help'),

Share This Page