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

Chris D

XenForo developer
Staff member
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.webp

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.
 
Upvote 19
This suggestion has been implemented. Votes are no longer accepted.
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.)
 
Due to a number of different features available as of XF 2.0.0, this is now considered implemented.

The navigation manager mostly solves the problem but it's also possible to specify the selected tab in the content template.
 
Back
Top Bottom