Add Tab through Addon

Grinch

Member
Hey guys, I'm pretty new to web development so please bear with me a bit.

I'm working on an addon and I cannot for the life of me figure out how to go about adding a tab with it. Most search results for xenforo.com lead me to people saying 'use Nodes as Tabs' which isn't actually a solution to my need.

If someone could help me out a bit here I would be most grateful. :)
 
Hi @Grinch
If you take a look at Dependencies/Public.php, function _getNavigationContainerParams(), you will see a XenForo_CodeEvent called navigation_tabs
You call this event by creating a Code Event Listener for navigation_tabs which calls your PHP file that includes a function such as addMyTab(array &$extraTabs, $selectedTabId)
This function adds your tab to the $extraTabs array as follows:
PHP:
$extraTabs['MyTab'] = array(
    'title' => new XenForo_Phrase('mytab_name'), // title of tab
    'href' => XenForo_Link::buildPublicLink('mytab_location'), // where to link your tab to when tab title is clicked
    'position' => mytab_location_within_the_tabs, //  location of tab such as 'home', 'middle', or 'end'
    'linksTemplate' => 'mytab_template' // name of your template that displays what it is you want the tab to show
);
I hope this helps.
 
Hi @Grinch
If you take a look at Dependencies/Public.php, function _getNavigationContainerParams(), you will see a XenForo_CodeEvent called navigation_tabs
You call this event by creating a Code Event Listener for navigation_tabs which calls your PHP file that includes a function such as addMyTab(array &$extraTabs, $selectedTabId)
This function adds your tab to the $extraTabs array as follows:
PHP:
$extraTabs['MyTab'] = array(
    'title' => new XenForo_Phrase('mytab_name'), // title of tab
    'href' => XenForo_Link::buildPublicLink('mytab_location'), // where to link your tab to when tab title is clicked
    'position' => mytab_location_within_the_tabs, //  location of tab such as 'home', 'middle', or 'end'
    'linksTemplate' => 'mytab_template' // name of your template that displays what it is you want the tab to show
);
I hope this helps.

What would I need to do to handle tab selection as well?
 
Back
Top Bottom