Navigation link de-selects Forums tab

AndyB

Well-known member
Hello,

I have an add-on I'm developing called Advanced Search. There is a link to the add-on located under the Forums tab. You can see it here:

http://www.southbayriders.com/forums/

When I click the Advanced Search link, the Forums tab is no longer highlighted. How can I make the Forums tab continue to be selected after I click the Advanced Search link?

Thank you.
 
For example:

../Route/Prefix/AdvancedSearch.php

Code:
/**
* Match a specific route for an already matched prefix.
*
* @see XenForo_Route_Interface::match()
*/

public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
{
    return $router->getRouteMatch('AdvancedSearch_ControllerPublic_AdvancedSearch', $routePath, 'forums');
}
 
Hi Valhalla,

Thank you for taking the time to look into this. The code example you provided, where would I use this?

This is what I currently have for my PHP file Andy/AdvancedSearch/ControllerPublic/AdvancedSearch.php

PHP:
<?php

class Andy_AdvancedSearch_ControllerPublic_AdvancedSearch extends XenForo_ControllerPublic_Abstract
{
	public function actionIndex()
	{
		// get user group permissions
		if (!XenForo_Visitor::getInstance()->hasPermission('advancedSearchGroupID', 'advancedSearchID'))
		{
			throw $this->getNoPermissionResponseException();
		}

		// send to template
		return $this->responseView('Andy_AdvancedSearch_ViewPublic_AdvancedSearch', 'andy_advancedsearch');
	}
 
If I try this:

PHP:
		// send to template
		return $this->responseView('Andy_AdvancedSearch_ViewPublic_AdvancedSearch', 'andy_advancedsearch', 'forums');

I get this error:

pic001.webp
 
Have you created a Route Prefix for your new page? (In Development -> Route Prefixes)

Screen Shot 2014-11-06 at 20.03.16.webp

Once you have created the new Route Class as above, you can refer to your ControllerPublic file (the one you posted above):

PHP:
<?php

class Andy_AdvancedSearch_Route_Prefix_AdvancedSearch implements XenForo_Route_Interface
{
    /**
    * Match a specific route for an already matched prefix.
    *
    * @see XenForo_Route_Interface::match()
    */
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        return $router->getRouteMatch('Andy_AdvancedSearch_ControllerPublic_AdvancedSearch', $routePath, 'forums');
    }
}

?>

Screen Shot 2014-11-06 at 20.13.04.webp
 
Last edited:
Got it!

Thank you so much, Valhalla.

Adding 'forums' to the Andy/AdvancedSearch/Route/Prefix/AdvancedSearch was all I was missing. I knew how to do this, but forgot that is where I needed to add 'forums'.
 
Top Bottom