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

$this->_routeMatch->setSections('home');

Chris D

XenForo developer
Staff member
#1
A lot of people are beginning to want to change their index page route to other things. Sometimes this might be a custom page, or some other add-on, e.g. Featured Threads, Xen Media Gallery, Resource Manager etc.

With a small amount of code, in a controller you can override the active navigation tab:

PHP:
$this->_routeMatch->setSections('home');
But home does not activate the "Home" tab. It actually deactivates all tabs.

upload_2014-1-18_14-47-36.png

I believe primarily the Home tab has been designed to be used how it is used here. To point to an external page. And although in 1.1.X and below this may have been its only possible usage, now it has other uses.

An add-on developer may want to:
PHP:
if ($options->indexRoute == 'my-route')
{
    $this->_routeMatch->setSections('home');
}
I feel that setting the section to home should select the home tab. If there was additionally a method to override the navigation tab links for that tab as well, that'd be incredibly useful.
 

Mike

XenForo developer
Staff member
#2
In general, this is more of a suggestion, as there is no home "tab" per se -- it's just a link. The code has no concept of selecting it, what links would go under it, etc. (Hence why we generally suggest add-ons provide their own tab if it fits their needs.)